request = $request; } /** * @param $model * @param RepositoryInterface $repository * * @return mixed */ public function apply($model, RepositoryInterface $repository) { // this is a Example //if ($this->request->filled('name')) { // $model = $model->where('name', '=', $this->request->get('name')); //} if ($this->request->filled('name')) { $model = $model->where('name', 'like', '%' . $this->request->get('name') . '%'); } if ($this->request->filled('code')) { $model = $model->where('code', 'like', '%' . $this->request->get('code') . '%'); } if ($this->request->filled('status')) { $model = $model->where('status', '=', $this->request->get('status')); } // $admin = login_admin(); // switch ($admin['type']) { // case AdminTypeEnum::ADMIN: // $company_id = $admin['company_id']; // if ($company_id) $model = $model->where('company_id', '=', $company_id); // break; // } // $model = $model->orderByDesc('sort')->orderByDesc('id'); return $model; } }