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('course_id')) { $val = $this->request->get('course_id'); $model = $model->where('course_id', '=', $val); } if ($this->request->filled('course_video_id')) { $val = $this->request->get('course_video_id'); $model = $model->where('course_video_id', '=', $val); } if ($this->request->filled('title')) { $title = $this->request->get('title'); $model = $model->where('title', 'like', "%{$title}%"); } if ($this->request->filled('me')) { $model = $model->where('user_id', login_user_id()); } if (!$this->request->filled('orderBy')) { $model = $model->orderByDesc('id'); } if (isApiModule()) { $model = $model->where('status', ModelStatusEnum::OK); } return $model; } }