dataRange() ->catchSearch() ->append(['device_type_name','creator_name','fan_model_name']) ->order($this->aliasField('id'), 'desc') ->paginate(); return $res; } /** * 名称搜索 */ public function searchNameAttr($query, $value, $data) { return $query->where('name', 'like', '%'.$value.'%'); } /** * 设备类型搜索 */ public function searchDeviceTypeAttr($query, $value, $data) { return $query->where('device_type', '=', $value); } /** * 设备类型名称 */ public function getDeviceTypeNameAttr(){ $value=$this->getData('device_type'); return (new SysDictData())->getValueByCode('Maintenance', $value) ?: ''; } public function getFanModelAttr() { $value = $this->getData('fan_model'); return $value?intval($value):null; } public function getFanModelNameAttr() { $value = $this->getData('fan_model'); $where[] = ['device_type','=',4]; $where[] = ['id','=',$value]; $name = Db::name('device_mold')->where($where)->value('name'); return $name; } }