Laravel 10.11 Released
Published on by Paul Redmond
The Laravel team released Laravel 10.11 this week with the ability to retrieve a timestamp Carbon instance from a UUID, making the Sleep
class macroable, and a new Precognition-Success
header for verifying a successful Precognition response, and more.
Let's dive in and see what's new this week:
Timestamp retrieval as a Carbon instance from UUID/ULID
@DarkGhostHunter contributed retrieving a Carbon instance from a UUID or ULID:
use Illuminate\Support\Facades\Date; // Dates from ULID$date = Date::createFromUid('01H06ZMA15EBJASEXHWJC1SY5F'); // Dates from UUID$date = Date::createFromUid('01880dfa-2825-72e4-acbb-b1e4981cf8af'); $date = Date::createFromUid($uid); if (is_null($date)) { return 'The UID is invalid';} elseif (!$date) { return 'The UID has no timestamp';} return $date;
Add Precognition-success header
Tim MacDonald contributed a Precognition-Success: true
response header. When the client receives a 204
, it doesn't alone guarantee Precognition succeeded, so this additional header ensures Precognition was successful. See Pull Request #47081 for more details.
Make the Sleep class macroable
Bradie Tilley contributed making the Sleep
class introduced in Laravel 10.10 macroable. An example was provided in the pull request's description:
// AppServiceProviderSleep::macro('forConfiguredTime', static function () { $milliseconds = DB::table('settings') ->where('key', 'sleep_after_action') ->first() ->value ?? 1000; return Sleep::for($milliseconds)->milliseconds();});
Release Notes
You can see the complete list of new features and updates below and the diff between 10.10.0 and 10.11.0 on GitHub. The following release notes are directly from the changelog:
v10.11.0
Added
- Added the ability to extend the generic types for DatabaseNotificationCollection (#47048)
- Added
/Illuminate/Support/Carbon::createFromId()
(#47046) - Added Name attributes on slots (#47065)
- Added Precognition-Success header (#47081)
- Added Macroable trait to Sleep class (#47099)
Fixed
- Fixed
Illuminate/Database/Console/ShowModelCommand::getPolicy()
(#47043)