74 lines
1.8 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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);
}
}