123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace catchAdmin\alarm\model;
- use catcher\base\CatchModel as Model;
- use catchAdmin\permissions\model\DataRangScopeTrait;
- use catchAdmin\system\model\SysDictData;
- class BwList extends Model
- {
- use DataRangScopeTrait;
- // 表名
- public $name = 'bw_list';
- // 数据库字段映射
- public $field = array(
- 'id',
- // 名称
- 'name',
- // 名单类型(0-黑名单,1-白名单)
- 'type',
- // 标签类型
- 'rfid_type',
- // 启用停用(0-停用,1-启用)
- 'state',
- // 备注
- 'remark',
- // 创建人ID
- 'creator_id',
- // 创建时间
- 'created_at',
- // 更新时间
- 'updated_at',
- // 软删除
- 'deleted_at',
- );
- /**
- * 列表
- */
- public function getList()
- {
- $res=$this->dataRange()
- ->catchSearch()
- ->append(['type_text','rfid_type_text'])
- ->order($this->aliasField('id'), 'desc')
- ->paginate();
- return $res;
- }
- //根据姓名搜索
- public function searchNameAttr($query, $value, $data)
- {
- return $query->where('name', 'like', '%' . $value . '%');
- }
- public function searchTypeAttr($query, $value, $data)
- {
- return $query->where('type', $value );
- }
- public function searchStateAttr($query, $value, $data)
- {
- return $query->where('state', $value );
- }
-
- public function getTypeAttr($value){
-
- return (string)$value;
- }
- public function getTypeTextAttr($value){
- $type = $this->getData('type');
- return $type ?'白名单': '黑名单';
- }
- public function getRfidTypeTextAttr($value){
- $rfid_type = $this->getData('rfid_type');
- return (new SysDictData())->getValueByCode('RFID_TYPE_OPTION', $rfid_type) ?: '';
- }
- }
|