feat: 产品
refactor: 产品详情页seo
This commit is contained in:
@@ -17,6 +17,28 @@ class ProductModel extends ProductBaseModel
|
||||
// 软件删除时间字段
|
||||
protected $deleteTime = 'deleted_at';
|
||||
|
||||
// 关联产品分类
|
||||
public function category()
|
||||
{
|
||||
return $this->belongsTo(ProductCategoryModel::class, 'category_id', 'id');
|
||||
}
|
||||
|
||||
// 关联sku
|
||||
public function sku()
|
||||
{
|
||||
return $this->hasMany(ProductSkuModel::class, 'product_id', 'id');
|
||||
}
|
||||
|
||||
// 所属分类范围查询
|
||||
public function scopeByCategory($query, $category)
|
||||
{
|
||||
if (is_array($category)) {
|
||||
$query->whereIn('category_id', $category);
|
||||
return;
|
||||
}
|
||||
$query->where('category_id', '=', $category);
|
||||
}
|
||||
|
||||
// 所属语言范围查询
|
||||
public function scopeLanguage($query, $language)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user