You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
1.8 KiB
73 lines
1.8 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
|
// +----------------------------------------------------------------------
|
|
// | Author: CRMEB Team <admin@crmeb.com>
|
|
// +----------------------------------------------------------------------
|
|
namespace app\model\product\sku;
|
|
|
|
use crmeb\basic\BaseModel;
|
|
use crmeb\traits\ModelTrait;
|
|
use think\Model;
|
|
|
|
/**
|
|
* 商品属性Model
|
|
* Class StoreProductAttr
|
|
* @package app\common\model\product
|
|
*/
|
|
class StoreProductAttr extends BaseModel
|
|
{
|
|
use ModelTrait;
|
|
|
|
/**
|
|
* 模型名称
|
|
* @var string
|
|
*/
|
|
protected $name = 'store_product_attr';
|
|
|
|
/**
|
|
* 规格获取器
|
|
* @param $value
|
|
* @return false|string[]
|
|
*/
|
|
protected function getAttrValuesAttr($value)
|
|
{
|
|
return explode(',', $value);
|
|
}
|
|
|
|
/**
|
|
* 规格修改器
|
|
* @param $value
|
|
* @return string
|
|
*/
|
|
protected function setAttrValuesAttr($value)
|
|
{
|
|
return is_array($value) ? implode(',', $value) : $value;
|
|
}
|
|
|
|
/**
|
|
* 商品搜索器
|
|
* @param Model $query
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchProductIdAttr($query, $value)
|
|
{
|
|
$query->where('product_id', $value);
|
|
}
|
|
|
|
/**
|
|
* 商品类型搜索器
|
|
* @param Model $query
|
|
* @param $value
|
|
* @param $data
|
|
*/
|
|
public function searchTypeAttr($query, $value)
|
|
{
|
|
$query->where('type', $value);
|
|
}
|
|
}
|
|
|