public function getListStaff(string $searchString = '')
{
return Staff::with(['citizen_identification' => function ($query) {
$query->where('full_name', 'like', '%' . $searchString . '%');
}])
->where('phone', 'like', '%' . $searchString . '%')
->orWhere('email', 'like', '%' . $searchString . '%')
->paginate(2);
}
I use Repository in project livewire of me, i newbie use livewire, when i code method getListStaff is faulty, i try fix, but not success, please help me fix... Thanhks bros
Because I wrong syntax or visual code error or so ???
CodePudding user response:
It seems like you have missed use statement for searchstring.
In any case, based from you question its not clear what is not working.
return Staff::with([
'citizen_identification' => function ($query) use ($searchString) {
$query->where('full_name', 'like', '%'.$searchString.'%');
},
])
->where('phone', 'like', '%'.$searchString.'%')
->orWhere('email', 'like', '%'.$searchString.'%')
->paginate(2);