π₯ #Laravel Eloquent Models - [ π₯·π» "hidden" properties ]
We are all familiar with $table, $fillable, $dates and $appends and a few more but did you know there are more undocumented properties that we can make use of in our Laravel models?
Here is the complete list 𧡠ππ»
1οΈβ£ You can specify the relations to eager load on every query for that model using $with
2οΈβ£ You can set how the relationship counts that should be eager loaded on every query for a given model
3οΈβ£ You can enable or disable lazy loading for a model using $preventsLazyLoading
4οΈβ£ You can limit the number of models to return for pagination using $perPage
5οΈβ£ You can indicate if the model was inserted during the current request lifecycle using $wasRecentlyCreated
6οΈβ£ If you want the object's string representation to be escaped when __toString is invoked you can set $escapeWhenCastingToString to true
7οΈβ£ You can indicate if broadcasting is currently enabled for a model using $isBroadcasting
8οΈβ£
BONUS - For all of the available options you can check out Laravel's model class:
github.com/laravel/framewβ¦
Share this Scrolly Tale with your friends.
A Scrolly Tale is a new way to read Twitter threads with a more visually immersive experience.
Discover more beautiful Scrolly Tales like this.