#development #laravel #php #reading-list

🔗 Configure Laravel to use Immutable dates by default

By default, Laravel uses Carbon for dates, but the object returned by the \Illuminate\Support\Facades\Date helper is mutable.

To configure Laravel to use CarbonImmutable instead, call this method in your AppServiceProvider's boot() method:

 1use Carbon\CarbonImmutable;
 2use Illuminate\Support\Facades\Date;
 4class AppServiceProvider extends ServiceProvider
 6    public function boot()
 7      {
 8        Date::use(CarbonImmutable::class);
 9    }

Just make sure to use Laravel's Date facade instead of Carbon directly in your application code.

continue reading on rias.be

⚠️ This post links to an external website. ⚠️