I have two nested relations, One is requester.link
and requester.company
, I want both to be search for the word $request->search
.
The code is self explanatory:
$clients = \App\AcceptedConnection::with('requester.link', 'requester.company')
->where('accepter_id', Auth::user()->id)
->orWhereHas('requester.link', function ($query) use ($request) {
$query->orWhere('name', $request->search);
})->orWhereHas('requester.company', function ($query) use ($request) {
$query->orWhere('email', $request->search);
$query->orWhere('firstname', $request->search);
$query->orWhere('lastname', $request->search);
})->get();
It gives me the records for anything searched, It returns records even the search is not matching, Search anything and it will give you records,
What am i missing ?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire