I have the following, I am getting all the clients that belong to a user with eloquent, these clients show them in a select in the blade view, my problem is that in the clients table there is a field that specifies if the client is already is assigned or not, I need to remove from the collection of clients those that are already assigned, so that in the blade view only show me those that are not assigned I am trying this way:
public function getClients()
{
//Con esto obtenemos todos los clientes que pertenezcan al usuario autenticado
$client = Auth::user()->clients()->get();
foreach ($client as $clients) {
if ($clients->community =='asigned' && $clients->account_director == 'asigned') {
$client->pull($clients);
}
}
dd($client);
return $client;
}
but I get this error array_key_exists (): The first argument should be either a string or an integer ", in what way could the clients that are already assigned be removed from the collection?