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'); } } }