初始化

This commit is contained in:
2026-08-08 18:27:38 +08:00
parent efc150c937
commit 060eb79c09
336 changed files with 24613 additions and 15 deletions
+52
View File
@@ -0,0 +1,52 @@
<?php
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\SoftDeletes;
class Product extends Model
{
use SoftDeletes;
protected $fillable = [
'category_id',
'name',
'slug',
'model',
'summary',
'description',
'specs',
'cover',
'status',
'sort',
'seo_title',
'seo_description',
];
protected $casts = [
'category_id' => 'integer',
'sort' => 'integer',
];
public function category(): BelongsTo
{
return $this->belongsTo(Category::class, 'category_id');
}
public function scopePublished($query)
{
return $query->where('status', 'published')->orderBy('sort')->orderBy('name');
}
public function seoTitle(): string
{
return $this->seo_title ?: ($this->name . ' - 深圳市云创芯电子有限公司');
}
public function seoDescription(): string
{
return $this->seo_description ?: ($this->summary ?: $this->name);
}
}