Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ITellMyselfSecrets's avatar

Laravel Magic Query Builder

How much magic can be used in the query builder? Just curious. Looking for examples that are not in the documentation

0 likes
1 reply
bobbybouwmann's avatar
Level 88

The one I can think is probably this one

$user = User::whereNameAndEmailAndActive('John Doe', '[email protected]', true)->firstOrFail();

This produce a query like

select * from users where name = 'John Doe' and email = '[email protected]' and active = '1'
1 like

Please or to participate in this conversation.