1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <?php
- namespace catchAdmin\alarm\model;
- use catcher\base\CatchModel as Model;
- use catchAdmin\permissions\model\DataRangScopeTrait;
- use catchAdmin\system\model\SysDictData;
- class ControlAlarm extends Model
- {
- use DataRangScopeTrait;
- // 表名
- public $name = 'control_alarm';
- // 数据库字段映射
- public $field = array(
- 'id',
- // 车牌
- 'plate_no',
- // 车辆标签
- 'rfid_sn',
- // 报警地点
- 'address',
- // 报警类型
- 'alarm_type',
- // 状态
- 'state',
- // 备注
- 'remark',
- // 创建人ID
- 'creator_id',
- // 创建时间
- 'created_at',
- // 更新时间
- 'updated_at',
- // 软删除
- 'deleted_at',
- );
- /**
- * 列表
- */
- public function getList()
- {
- $res=$this->dataRange()
- ->catchSearch()
- ->append(['state_text'])
- ->order($this->aliasField('id'), 'desc')
- ->paginate();
- return $res;
- }
- public function searchPlateNoAttr($query, $value, $data)
- {
- return $query->where('plate_no', 'like', '%' . $value . '%');
- }
- public function searchRfidSnAttr($query, $value, $data)
- {
- return $query->where('rfid_sn', 'like', '%' . $value . '%');
- }
- public function searchAlarmTypeAttr($query, $value, $data)
- {
- return $query->where('alarm_type', $value);
- }
-
- public function getStateTextAttr($value){
- $state = $this->getData('state');
- return (new SysDictData())->getValueByCode('AlarmHandleState', $state) ?: '';
- }
- public function getAlarmTypeAttr($value){
-
- return (new SysDictData())->getValueByCode('AlarmType', $value) ?: '';
- }
- }
|