dataRange() ->catchSearch() ->append(['creator_name', 'insurance_name', 'vehicle_plate']) ->order($this->aliasField('id'), 'desc') ->paginate(); return $res; } /** * 获取保险记录导出列表 */ public function getInsureExportList() { $res = $this->dataRange() ->catchSearch() ->append(['creator_name', 'insurance_name']) ->order($this->aliasField('id'), 'desc') ->select(); return $res; } //根据车牌搜索 public function searchVehiclePlateAttr($query, $value, $data) { $value = (new Vehicle())->where('license_plate', $value)->value('id'); return $query->where('vehicle_id', $value); } //根据保险搜索 public function searchInsuranceNameAttr($query, $value, $data) { $value = (new Insurance())->where('name', $value)->value('id'); return $query->where('insurance_id', $value); } //获取车牌号码 public function getVehiclePlateAttr($value) { return (new Vehicle())->where('id', $this->getData('vehicle_id'))->value('license_plate'); } //获取保险名称 public function getInsuranceNameAttr($value) { return (new Insurance())->where('id', $this->getData('insurance_id'))->value('name'); } //获取操作用户 public function getCreatorNameAttr($value) { return (new Users())->where('id', $this->getData('creator_id'))->value('username'); } //获取生效时间 public function getStartAtAttr($value) { return date('Y-m-d H:i:s',$value); } //获取过期时间 public function getEndAtAttr($value) { return date('Y-m-d H:i:s',$value); } }