@msslgomez in your case, it makes no difference, but if you were chaining then its neater and more readable.
eg:
$var = Model::query()
->where('some-field','some-value')
->where('some-field2','some-value2')
->sortAsc()
->get();
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
What difference does it make to use this when making a query to the db? I have a coworker who always puts this is his queries but I don't think it's needed as the query is executed the same with or without it. for example:
What is the difference in these:
$var= Model::query()->findOrFail($id);
$var= Model::findOrFail($id);
I'm just wondering what is the point of doing this and for what?
Please or to participate in this conversation.