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

oroalej's avatar

Shortcut of Where.

Hi All,

If you would like to query like this

Modal::where('some_column', 'some value')->get();

You can code it this way.

Modal::whereSomeColumn('some value')->get();

The result will be the same.

Unfortunately, this will only work when you are looking for the equal value. It doesn't work with !=.

0 likes
3 replies
tykus's avatar

Those magic where methods have been taken out of the Laravel docs in recent versions; I wonder if they will continue to be supported...

crnkovic's avatar

I hope they remove it from 5.7. Too much magic is bad for you. I strongly suggest not using this but sticking to default where($attribute, $value)

Cronix's avatar

Yep. Magic methods are slower than real methods. Just don't use whereColumnName(). It's slower than just using where(column, operator, value)

Please or to participate in this conversation.