feat: 产品

refactor: 产品详情页seo
This commit is contained in:
2025-04-24 10:21:45 +08:00
parent 49c865bf85
commit e2265629f9
43 changed files with 592 additions and 63 deletions

View File

@@ -0,0 +1,33 @@
<?php
declare (strict_types = 1);
namespace app\index\model;
use app\common\model\ProductSkuBaseModel;
/**
* 产品SKU模型
* @mixin \think\Model
*/
class ProductSkuModel extends ProductSkuBaseModel
{
// json字段
protected $json = ['photo_album'];
protected $jsonAssoc = true;
// 关联sku属性
public function attr()
{
return $this->hasMany(ProductSkuAttrModel::class, 'sku_id', 'id');
}
// 所属产品范围查询
public function scopeByProductId($query, $product)
{
if (is_array($product)) {
$query->whereIn('product_id', $product);
return;
}
$query->where('product_id', '=', $product);
}
}