The Laravel team released 8.13 this week and updated the change log detailing all new features from last week's 8.12 release. New features added to Laravel in recent weeks have come with exciting updates, let's look at what's new!
8.12: Create a Custom Observer
8.12: 8.x Lazy Method in 8.x Eloquent Factory
Mathieu TUDISCO continue a model in the database when it is called made you contributed to the ability to create a call back. In earlier versions of Laravel, factorybuilder's
lazy()there was a method that created the record only when it was called. Now the 8.x factory can do the same:
$factory = User::factory()->lazy();
$factory = User::factory()->lazy(['name' => 'Example User']); $factory();
8.12: Encrypted String Eloquent Cast
Jason McCreary contributed to a meaningful cast that would allow a simple string to be encrypted and decrypted:
public $casts = [
'access_token' => 'encrypted',
8.12: New withColumn () to support Aggregation Functions
Halil Laleh a contribution
withColumna method to support more SQL collection functions, such as
AvgOn relationships, etc.:
You may want to check out #34965 for more details.
8.12: Add a Description to Eloquent / Query Builder
explain() contributed to the query builder/ meaningful constructor in a way that allows you to import the comment query from the constructor:
Webhook::where('event', 'users.registered')->explain()Webhook::where('event', 'users.registered')->explain()->dd()
explain()to check in the description
dd()you can search and leave the description.
8.12: Full PHP 8 Support
Dries Vints is working to add PHP 8 support to the Laravel ecosystem, including coordinating various libraries (both first and third-party libraries) and many efforts. Thanks to Dries and anyone interested in preparing Laravel for the next major PHP release!
8.12: Route Registration Method
Gregori Piñeres has contributed to some methods that you can add to route parameters:
// Before. This is still a valid, acceptable way of defining routes
'author' => '[0-9]+',
'book' => '[a-zA-Z]+'
]);// New optional syntax
->whereAlpha('book');// New methods support multiple args