'=', 'created_at' => 'like', ]; public function model() { return Model::class; } /** * 数据格式化 * * @param mixed $result * * @return mixed */ public function transform($model) { return $model->toArray(); } /** * 查询条件 * * @return void */ public function withConditions(array $conditions = []) { if (isset($conditions['id'])) { $conditions['id'] = array_wrap($conditions['id']); $this->model = $this->model->whereIn('id', $conditions['id']); } if (isset($conditions['tag'])) { $this->model = $this->model->where('tag', $conditions['tag']); } if (isset($conditions['starttime'])) { $this->model = $this->model->where('created_at', '>=', Carbon::parse($conditions['starttime'])); } if (isset($conditions['endtime'])) { $this->model = $this->model->where('created_at', '<=', Carbon::parse($conditions['endtime'])); } return $this; } }