request = $request; } /** * @param $model * @param RepositoryInterface $repository * * @return mixed */ public function apply($model, RepositoryInterface $repository) { if ($this->request->filled('user_id')) { $user_id = $this->request->get('user_id'); $model = $model->where('user_id', '=', $user_id); } if ($this->request->filled('complaint_phone')) { $complaint_phone = $this->request->get('complaint_phone'); $model = $model->where('complaint_phone', 'like', "%{$complaint_phone}%"); } if ($this->request->filled('content')) { $content = $this->request->get('content'); $model = $model->where('content', 'like', "%{$content}%"); } if ($this->request->filled('deal_department_id')) { $deal_department_id = $this->request->get('deal_department_id'); $model = $model->where('deal_department_id', '=', $deal_department_id); } if ($this->request->filled('deal_status')) { $deal_status = $this->request->get('deal_status'); $model = $model->where('deal_status', '=', $deal_status); } $model = $model->orderBy('created_at', 'desc'); return $model; } }