Laravel Community Tools by
Tighten
Laravel Versions
PHP Releases
Nova Packages
Laravel Tricks
Forge Recipes
Toggle navigation
Log in
Log in
Tag "eloquent" tricks
24 tricks
Eloquent
prevent update a field
maybe this is a nice way to prevent an eloquent model field being updated with mutators like this:
Tefoh
6 years ago
8636
eloquent
database
Eloquent
Laravel OrderBy relationship counter
If you want to count the number of results from a relationship without actually loading them you may use the "withCount" method, which will place a "{relation}_count" column on your resulting models.
kupendra
6 years ago
12050
5.8
eloquent
models
Eloquent
Constraining Eager Loads
Sometimes you may wish to eager load a relationship, but also specify additional query constraints for the eager loading query. Here's an example:
BenaliDjam...
6 years ago
9628
eloquent
Eloquent
Using isDirty() to check Eloquent attribute changes
You might come up with a situation where you want to check if a given Eloquent attribute was changed compared with its original stored value.
laraning
7 years ago
25093
eloquent
Eloquent
get Enum values from database
with this trait you can get Enum values of a table /
nimahkh
7 years ago
12622
eloquent
database
Eloquent
See the SQL query that is being generated when using Eloquent or the Query Builder.
If you ever wanted to see the SQL query that is being generated when using the Eloquent or the Query Buider, you can simply use to `toSql` method.
wilburpowe...
8 years ago
3660
database
eloquent
« Previous
Next »
Showing
19
to
24
of
24
results
1
2
3