Fix Corporate Index

This commit is contained in:
2022-08-31 10:21:18 +07:00
parent 2efc5e44a2
commit f0acb340b7
4 changed files with 208 additions and 112 deletions

View File

@@ -23,10 +23,19 @@ class CorporateController extends Controller
* Display a listing of the resource.
* @return Renderable
*/
public function index()
public function index(Request $request)
{
$corporates = Corporate::query()
->paginate(0);
->when($request->search, function ($query, $search) {
return $query->where('name', 'LIKE', '%'.$search.'%');
})
->with('currentPolicy')
->withCount([
'employees',
'corporatePlans',
'corporateBenefits'
])
->paginate(2);
return $corporates;
}