XverseWallet
1 votes

Laravel 14 Adds a defaults() Method to Eloquent Models

Eloquent models set default attribute values with the $attributes property. It works for fixed values, but PHP only allows constant expressions in a property's default value, so you cannot call config(), now(), or a feature flag there. Laravel 14 adds a defaults() method that returns the same array from code that runs when the model is created.

Visit laravel-news.com

Laravel Laravel 14

0 comments

Sign in to join the conversation.

  • No comments yet.

More in Web Development