Example Analysis of WhereX in Laravel Eloquent
This article shares with you the content of the sample analysis of WhereX in Laravel Eloquent. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
WhereX
There is an elegant way to put this code:
$users = User::where ('approved', 1)-> get ()
Converted to this:
$users = User::whereApproved (1)-> get ()
Yes, you read it correctly, use the field name as a suffix to add to the where, and it can be run by magic.
In addition, there are some time-related predefined methods in Eloquent:
User::whereDate ('created_at', date (' YmurmMurd'); User::whereDay ('created_at', date (' d')); User::whereMonth ('created_at', date (' m')); User::whereYear ('created_at', date (' Y')); thank you for reading! This is the end of this article on "sample Analysis of WhereX in Laravel Eloquent". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!