request = $request; } /** * @param $model * @param RepositoryInterface $repository * * @return mixed */ public function apply($model, RepositoryInterface $repository) { if ($this->request->filled('course_id')) { $val = $this->request->get('course_id'); $model = $model->where('course_id', '=', $val); } if ($this->request->filled('status')) { $status = $this->request->get('status'); $model = $model->where('status', '=', $status); } if ($this->request->filled('user_id')) { $val = $this->request->get('user_id'); $model = $model->where('user_id', '=', $val); } if ($this->request->filled('ids')) { $ids = $this->request->get('ids'); $model = $model->whereIn('id', $ids); } if (!$this->request->filled('orderBy')) { $model = $model->orderByDesc('id'); } if (isApiModule()) { $model = $model->where('user_id', login_user_id()); } return $model; } }