123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- namespace catchAdmin\yunying\model;
- use catcher\base\CatchModel as Model;
- use catchAdmin\permissions\model\DataRangScopeTrait;
- class VehicleBrand extends Model
- {
- use DataRangScopeTrait;
- // 表名
- public $name = 'vehicle_brands';
- // 数据库字段映射
- public $field = array(
- 'id',
- // 品牌名称
- 'name',
- //状态
- 'status',
- //排序
- 'sort',
- // 创建人ID
- 'creator_id',
- // 创建时间
- 'created_at',
- // 更新时间
- 'updated_at',
- // 软删除
- 'deleted_at',
- );
- /**
- * 获取品牌列表
- */
- public function getBrandList($field,$order)
- {
- $res = $this->dataRange()
- ->catchSearch()
- ->order($this->aliasField($field), $order)
- ->paginate();
- return $res;
- }
- //根据名称搜索
- public function searchNameAttr($query, $value, $data)
- {
- return $query->where('name', 'like', '%'.$value.'%');
- }
- //根据状态搜索
- public function searchStatusAttr($query, $value, $data)
- {
- return $query->where('status',$value);
- }
- }
|