// +---------------------------------------------------------------------- namespace app\admin\model\store\paramter; use think\Model; class Parameter extends Model { protected $connection = 'shop'; protected $pk = 'parameter_id'; // public static function tablePk(): string // { // return 'parameter_id'; // } // public static function tableName(): string // { // return 'parameter'; // } public function searchTemplateIdAttr($query, $value) { $query->where('template_id',$value); } /** * TODO 搜索 * @param $where */ public function getSearch(array $where) { foreach ($where as $key => $item) { if ($item !== '') { $keyArray[] = $key; $whereArr[$key] = $item; } } // var_dump($where); $class = get_called_class(); if(empty($keyArray)){ return $class::self(); }else{ return $class::withSearch($keyArray, $whereArr); } } }