Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of WhereX in Laravel Eloquent

Shulou Source: shulou.com Published: 2022-06-01 04:35:28 09月10日 Update

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!

Tags: Examples analysis content methods more articles good practical elegant code masterpieces suffixes fields articles ways time see knowledge magic reference Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Information MariaDB Redmi Shulou Technology