Laravel Pro Tips
#migrations #models
π₯ #Laravel Tip: you can define default values for columns in two places: Migrations and models. Via Models you can specify default attribute values and change them time by time only in code level, while in migration you need to write extra migration. #Laravel $Tip #Php
Laravel Eloquent
#blade #directives
π₯ #Laravel Tip: Version 9 of the framework includes the new @checked and @selected directives for use in Blade templates. They are a nice addition that makes it easier to define whether a checkbox is checked, or which value a dropdown should be set to.
Matt Kingshott
#eloquent #scopes #relationships
π₯ #Laravel Tip: Data leakage from incorrectly scoped queries is a major problem. One way of reducing the risk of it happening, is to always define and use relationship methods on your models. That way they will be automatically scoped.
#faker
A quick one that I *always* forget about -- Faker::numerify, allowing you to generate numeric data in a specific pattern ππ
Steve Bauman π
#dates #accessors #mutators #timezones
πΆοΈ #Laravel Tip: Use Laravel Accessor/Mutator to ππ²π Date field in UTC and π΄π²π Date field in user's current Timezone. Working with dates with timezones is always tricky & challenging πͺ #PHP #Developers #100daysofcodechallenge
Bilal Haidar
#eloquent #models #events
π₯π #Laravel Tip: If you ever need to save a model but you don't want to trigger any model events, you can use this method: `$user->saveQuietly` #Laravel #Tip #Eloquent
#routes
I'm reading the Laravel 9 docs from scratch and TIL you can write your route restrictions in a more expressive way:
Duilio Palacios
#eloquent #dates
πΆοΈ #Laravel tip: Eloquent has a rich set of πΏππ©π π¬πππ§π() statements. Let's check them together π₯ - whereDate() - whereTime() - whereYear() - ... Comment below if I missed any π» #PHP #developers
As of Laravel 9, we can use the new "pushOnce" directive in our Blade views π #laravel #php
Ash Allen π