DEV Community

loading...

Discussion on: Making the advanced search query with Eloquent-Builder in Laravel

mohammadfouladgar profile image
Fouladgar.dev Author

Yes,you can.
EloquentBuilder return an instance of Builder:

return EloquentBuilder::to(Blog::class,$filters)->with('latestPost')->OrderByDesc('latestPost.created_at')->get();
Thread Thread
farrukh_uet profile image
Farrukh

Thanks a lot for your reply.

I did not try it yet. Hope it will work as I wish.

Regards

Thread Thread
farrukh_uet profile image
Farrukh

Hi,

I used laravel debugger, when I used Eloquent Builder it shows me a (lot) number of queries.

is it normal or there is some method to reduce that

Regards
Farrukh

Thread Thread
mohammadfouladgar profile image
Fouladgar.dev Author

Hi,

The EloquentBuilder reduces the complexity of the queries and conditions of the code.Number of queries is not related to it.

Good luck

Thread Thread
farrukh_uet profile image
Farrukh

Thanks a lot dear