I have a list of ids I want to use to get items out of my database table.
$permittedClientIds = UsersClientsBridge::where('users_id', auth()->user()->id)->pluck('clients_id')->all();
$firstPermittedClientIds = UsersClientsBridge::where('users_id', auth()->user()->id)->pluck('clients_id')->first();
$clientsQuery = Clients::where('id', $firstPermittedClientIds);
foreach($permittedClientIds as $clientId) {
$clientsQuery->orWhere('id',$clientId);
}
$clientsQuery->get();
return view('client.clients', [
'clients' => $clientsQuery
]);
this $permittedClientIds contains 10
and 48
. When I manually write the orWhere query it returns the expected output but this is retuning 0 results.
I'm not sure if I need $firstPermittedClientIds
I only use it so I can initialize my query.