Immutable Date Casting in Laravel 8.53


August 5th, 2021


The Laravel team released 8.53 with immutable date and datetime casting, a queue monitoring command, and the latest changes in the 8.x branch:

Immutable Date and Datetime Casting

Adam Campbell contributed two new model casts: immutable_date and immutable_datetime. It maintains support for all current date/datetime functionality, except it returns a CarbonImmutable instance instead of Carbon.

Check out Pull Request #38199 for further details on the implementation. To get started with date casts, check out the Date Casting documentation.

Queue Monitoring Artisan Command

Mohamed Said contributed a new queue:monitor artisan command that will check the sizes of all queues provided and output them in a console:

queue:monitor output

A twiceDailyAt Scheduler Method

Doug Sisk contributed a twiceDailyAt scheduler frequency that allows setting the specific minutes past an hour to run at:

2 ->command('example:command')
3 ->twiceDailyAt(first: 2, second: 14, offset: 5);

"Accepted If" Validation Rule

Anees Khan contributed an accepted_if validation rule, which means a field must be "truthy" if another field under validation is equal to a specific value. This is useful for validating terms of service or other similar confirmation flows:

1$v = new Validator(
2 $trans,
3 [
4 'foo' => 'true',
5 'bar' => 'aaa'
6 ],
7 [
8 'foo' => 'accepted_if:bar,aaa'
9 ]

Release Video

Release Notes

You can see the full list of new features and updates below and the diff between 8.52.0 and 8.53.0 on GitHub.

Filed in:

Paul Redmond

Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.