filled('search')) { $baseQuery->whereAny( [ 'name', 'manager_name', 'poc_name', ], 'LIKE', "%{$request->search}%" ); } if ($query) { $query($baseQuery); } if ($paginate) { return $baseQuery->paginate($limit); } return $baseQuery->get(); } public function findById($id, callable $query = null) { $baseQuery = Client::query(); if (is_callable($query)) { $query($baseQuery); } return $baseQuery->where('id', $id)->firstOrFail(); } public function delete($id) { $client = $this->findById($id); $client->delete(); return $client; } public function create(array $data) { $client = Client::create($data); return $client; } public function update($id, array $data) { $client = $this->findById($id); $client->update($data); return $client; } public function pluck(callable $query = null) { $baseQuery = Client::query(); if (is_callable($query)) { $query($baseQuery); } return $baseQuery->pluck('name', 'id'); } }