12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- <?php
- namespace catchAdmin\yunying\model;
- use catchAdmin\permissions\model\DataRangScopeTrait;
- use catcher\base\CatchModel as Model;
- class VehicleColor extends Model
- {
- use DataRangScopeTrait;
- // 表名
- public $name = 'vehicle_colors';
- // 数据库字段映射
- public $field = array(
- 'id',
- // 颜色名称
- 'name',
- //状态
- 'status',
- //排序
- 'sort',
- // 创建人ID
- 'creator_id',
- // 创建时间
- 'created_at',
- // 更新时间
- 'updated_at',
- // 软删除
- 'deleted_at',
- );
- /**
- * 获取颜色列表
- */
- public function getColorList($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);
- }
- }
|