The Laravel team released version 12.45, featuring a JsonApiResource, an AsBinary castable class, a cloud storage email attachment helper, and more.
JSON:API Resource
Mior Muhammad Zaki contributed a JsonApiResource that allows you to output API resources using the JSON:API specification instead of the normal JsonResource:
use Illuminate\Http\Resources\JsonApi\JsonApiResource; class UserResource extends JsonApiResource {}
You can create JSON API resources using the make:resource command with the --json-api flag:
php artisan make:resource PostResource --json-api
See Pull Request #57571 for implementation details.
AsBinary Castable Class
Kacper Pruszyński contributed a AsBinary cast which stores values as binary bytes and exposes them as a string in PHP:
protected function casts(): array{ return [ 'id' => AsBinary::uuid(isRequired: true), 'public_id' => AsBinary::ulid(), // optional by default 'custom' => AsBinary::of('xor1', false), ];}
See Pull Request #58254 for implementation details.
Attachment Helper from Cloud Storage
Philo Hermans contributed a fromCloudStorage() attachment method, which makes it easier to add attachments to emails that are stored on the cloud:
// Before:Attachment::fromStorageDisk(Storage::getDefaultCloudDriver(), $attachment->path); // After:Attachment::fromCloudStorage($attachment->path);
See Pull Request #58201 for implementation details.
BackedEnum Support for Session Keys
Andy Hinkle contributed enum support for session keys, allowing you to pass the enum instead of the string value. This is in line with many other areas of the framework:
enum CheckoutSession: string{ case Cart = 'checkout.cart'; case ShippingAddress = 'checkout.shipping_address'; case PaymentMethod = 'checkout.payment_method';} // Beforesession()->put(CheckoutSession::Cart->value, $items);session()->get(CheckoutSession::Cart->value); // After (>=12.45)session()->put(CheckoutSession::Cart, $items);session()->get(CheckoutSession::Cart);
See Pull Request #58241 for implementation details.
Allow BackedEnum for Cache Keys
Similar to Enum support for Session keys, Jack Bayliss contributed BackedEnum support for cache keys:
// BeforeCache::put(AnalyticalGraph::PROFILE->value, $result); // AfterCache::put(AnalyticalGraph::PROFILE, $result);
See Pull Request #58246 for implementation details.
Mark Email as Unverified
Ali Khosrojerdi contributed a markEmailAsUnverified() method to compliment the markEmailAsVerified() method to reset email verification for a model record:
$user->markEmailAsUnverified();
See Pull Request #58255 for implementation details.
Add --readable flag to env:encrypt for Visible Key Names
Mathias Grimm contributed a --readable flag to the env:encrypt command:
This adds a new
--readableflag to theenv:encryptcommand that produces a line-by-line encrypted format where variable names remain visible but values are encrypted. This allows developers to see what environment variables exist without exposing sensitive data, and makes pull requests easier to review since reviewers can see which variables were added, removed, or renamed without needing to decrypt the file.
See Pull Request #58262 for implementation details.
v12.45.0 Release notes
You can see the complete list of new features and updates below and the diff between 12.44.0 and 12.45.0 on GitHub. The following release notes are directly from the changelog:
v12.45.0 Changelog
- [12.x] JSON:API Resource by @crynobone in https://github.com/laravel/framework/pull/57571
- [12.x] Add static constructor to guest middleware by @rodrigopedra in https://github.com/laravel/framework/pull/58204
- [12.x] Include JsonResource in
ModelInspectorresult by @cosmastech in https://github.com/laravel/framework/pull/58205 - [12.x] Add queue paused / resume events by @jackbayliss in https://github.com/laravel/framework/pull/58202
- [12.x] Add attachment helper method to add attachment from cloud storage by @PhiloNL in https://github.com/laravel/framework/pull/58201
- [12.x] Normalize APP_URL when generating filesystem URLs by @congkv in https://github.com/laravel/framework/pull/58210
- [12.x] Adjust AuthDatabaseTokenRepositoryTest by @jackbayliss in https://github.com/laravel/framework/pull/58206
- [12.x] Refactor
queuePausedlogic by @amirhshokri in https://github.com/laravel/framework/pull/58215 - Fix queue:listen timeout false positives after system sleep/wake by @ranjith67 in https://github.com/laravel/framework/pull/58216
- Change the remember cookie to store a MAC of the users password hash instead of their real password hash by @Synchro in https://github.com/laravel/framework/pull/58107
- Add connection details to QueryException error messages by @mathiasgrimm in https://github.com/laravel/framework/pull/58218
- [12.x] Adjust README test status badge by @jackbayliss in https://github.com/laravel/framework/pull/58222
- [12.x] Use constant for session ID length by @miladev95 in https://github.com/laravel/framework/pull/58224
- [12.x] Add type tests for PendingRequest.php by @shaedrich in https://github.com/laravel/framework/pull/58232
- feat: fire JobAttempted for sync jobs too by @veeshpath in https://github.com/laravel/framework/pull/58228
- [12.x] Adjust getEventDispatcher docblock to allow null return by @jackbayliss in https://github.com/laravel/framework/pull/58242
- [12.x] Extract
JobAttemptedevent dispatch to a separate method inSyncQueueby @amirhshokri in https://github.com/laravel/framework/pull/58240 - [12.x] ValidationException: update redirectTo property definition to include null by @cheack in https://github.com/laravel/framework/pull/58238
- [12.x] Add BackedEnum support for session keys by @ahinkle in https://github.com/laravel/framework/pull/58241
- [12.x] Update
upload-artifactaction by @jackbayliss in https://github.com/laravel/framework/pull/58250 - [12.x] Allow BackedEnum for Cache keys by @jackbayliss in https://github.com/laravel/framework/pull/58246
- [12.x] Add CommandFailed event and listenForFailures() for Redis connections by @miladev95 in https://github.com/laravel/framework/pull/58251
- [12.x] Fix: Change BackedEnum to UnitEnum in Authorizable trait by @webard in https://github.com/laravel/framework/pull/58258
- [12.x]Refactor: remove if and replace ? by @alipowerful7 in https://github.com/laravel/framework/pull/58256
- [12.x]Feat(MustVerifyEmail): add markEmailAsNotVerified() by @alipowerful7 in https://github.com/laravel/framework/pull/58255
- [12.x] Feat: add havingNotBetween && orHavingBetween && orHavingNotBetween by @alipowerful7 in https://github.com/laravel/framework/pull/58259
- [12.x] Formatting by @amirhshokri in https://github.com/laravel/framework/pull/58266
- [12.x] Refactor: add |null in dock block by @alipowerful7 in https://github.com/laravel/framework/pull/58268
- Add type guard for ChainedBatch/Queueable chained property before array_shift by @cyppe in https://github.com/laravel/framework/pull/58264
- [12.x] Add lang attributes to mail layout by @DBawazir2002 in https://github.com/laravel/framework/pull/58274
- [12.x] Clean up
Builderdocblocks by @amirhshokri in https://github.com/laravel/framework/pull/58270 - [12.x] Run Mockery cleanup via PHPUnit subscriber instead of explicit
m::close()calls by @lucasmichot in https://github.com/laravel/framework/pull/58278 - [12.x] Fix delayed Redis queue jobs with phpredis serialization enabled by @iazaran in https://github.com/laravel/framework/pull/58235
- [12.x] Add missing return type to Arr::array() by @mischasigtermans in https://github.com/laravel/framework/pull/58280
- [12.x] Add --readable flag to env:encrypt for visible key names by @mathiasgrimm in https://github.com/laravel/framework/pull/58262
- [12.x] Update fake method parameter type for disk by @murilo-plantae in https://github.com/laravel/framework/pull/58285
- [12.x] Fix typo in BelongsToMany::createOrFirst method name by @mischasigtermans in https://github.com/laravel/framework/pull/58284
- [12.x] Fix nth(), split() and splitIn() to throw InvalidArgumentException for invalid parameters by @mischasigtermans in https://github.com/laravel/framework/pull/58283
- [12.x] Fix Str::chopStart() and Str::chopEnd() returning empty string when given empty needle by @mischasigtermans in https://github.com/laravel/framework/pull/58286
- [12.x] Add AsBinary castable class by @plumthedev in https://github.com/laravel/framework/pull/58254
- [12.x] Add enum to
persistentFake()- and add tests by @jackbayliss in https://github.com/laravel/framework/pull/58287 - Update Inspiring Qoute's author name by @kerog in https://github.com/laravel/framework/pull/58292
- [12.x] Fix: add
@throws \InvalidArgumentExceptionto some dock block by @alipowerful7 in https://github.com/laravel/framework/pull/58289 - [12.x] Fix
Validator::sometimes()usage with attributes containing.by @crynobone in https://github.com/laravel/framework/pull/58291 - [12.x] Support "where subquery between values" by @gdebrauwer in https://github.com/laravel/framework/pull/58290
- Capture PDO read / write type for query events by @timacdonald in https://github.com/laravel/framework/pull/58156