123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace catchAdmin\alarm\model;
- use catcher\base\CatchModel as Model;
- use catchAdmin\permissions\model\DataRangScopeTrait;
- use catchAdmin\alarm\model\get\AlarmRecordsGet;
- class AlarmRecords extends Model
- {
- // 表名
- public $name = 'alarm_records';
- use DataRangScopeTrait;
- use AlarmRecordsGet;
- // 数据库字段映射
- public $field = array(
- 'id',
- // 卡号
- 'device_number',
- // 告警原因
- 'alarm_reason',
- // 处理人ID
- 'handler_id',
- // 开始时间
- 'start_time',
- // 结束时间
- 'end_time',
- // 告警状态
- 'state',
- 'alarm_type',
- // 备注
- 'comment',
- // 处理结果
- 'result',
- // 创建人ID
- 'creator_id',
- // 创建时间
- 'created_at',
- // 更新时间
- 'updated_at',
- // 软删除
- 'deleted_at',
- );
- public function getList()
- {
- return $this->dataRange()
- ->catchSearch()
- ->append(['result_text','end_time_text','start_time_text','device_name','reason_text'])
- ->order($this->aliasField('id'), 'desc')
- ->paginate();
- }
- /**
- * 学号
- */
- public function searchRealnameAttr($query, $value, $data)
- {
- return $query->where('realname', 'like', '%'. $value . '%');
- }
- /**
- * 学号
- */
- public function searchDeviceNumberAttr($query, $value, $data)
- {
- return $query->where('device_number', 'like', '%'. $value . '%');
- }
- /**
- * 告警原因
- */
- public function searchAlarmReasonAttr($query, $value, $data)
- {
- return $query->where('alarm_reason', $value);
- }
- /**
- * 是否处理
- */
- public function searchIsHandleAttr($query, $value, $data)
- {
- if($value==0){
- return $query->whereNull('end_time');
- }elseif($value==1){
- return $query->whereNotNull('end_time');
- }
- }
- }
|