I'm trying to make a query where returns me the results, based on a request word, but I have to filter with the relationship columns as well. Example:
Payment::byUnity($unityId)
->with(['contract:id,nome,sigla'])
->latest('id')
->where('id', 'LIKE', '%' . $request->input('search') . '%')
->orWhere('name', 'LIKE', '%' . $request->input('search') . '%')
->orWhere('contract.name', 'LIKE', '%' . $request->input('search') . '%')
->orWhere('contract.description', 'LIKE', '%' . $request->input('search') . '%')
->paginate(15)
How can I filter the "contract.name" on the query? Because the way of the example returns me error. Thanks in advance!
source https://stackoverflow.com/questions/67827348/laravel-how-to-make-a-search-filter-with-like-anything-in-relationship-columns
No comments:
Post a Comment