Never Miss a Laravel Release 🚀
The Laravel team released version 12.43, featuring new Eloquent collection methods to merge attribute visibility across a collection, make the HTTP client response macroable, and more.
As with most Laravel releases, there are tons of contributions, and we thank all those involved in continually making Laravel better. Let's look at what's new in Laravel 12.43!
Eloquent Collections mergeHidden() and mergeVisible() Methods
Mahmoud Ramadan contributed mergeHidden() and mergeVisible() methods to Eloquent collections, allowing you to adjust attributes across an entire collection:
use App\Models\User; $users = User::withWhereHas('comments')->get(); $users->mergeVisible(['updated_at']);
Make the HTTP Client Response Class Macroable
Kevin Bui contributed the Macroable trait to the HTTP client Response class:
use Illuminate\Http\Client\Response; Response::macro( 'movieFields', fn () => $this->collect()->only('title', 'year', 'runtime', 'director', 'plot')); $response = Http::get(...);$response->movieFields();
Make PendingDispatch::afterResponse conditional
@kenneth-saey contributed an update to the PendingDispatch afterResponse() method that allows you to conditionally dispatch a job after the response is sent to the browser:
// Before if (app()->environment('local')) { MyJob::dispatch($myData) ->afterResponse();} else { MyJob::dispatch($myData);} // AfterMyJob::dispatch($myData) ->afterResponse(! app()->environment('local'));
Let Storage::fake() Accept an Enum Disk Name
Bert Bredewold contributed the ability to pass an Enum for the disk name when using the storage fake. This puts the fake() method in alignment with the Storage::disk() method:
// New in Laravel 12.43Storage::fake(Disk::Local); // Already possible before Laravel 12.43Storage::disk(Disk::Local);
Test Response assertFailedDependency Helper
Artyom Osepyan contributed a test assertion for HTTP 424 Failed Dependency client error response code. The Failed Dependency response indicates that the method could not be performed on the resource because the requested action depended on another action, and that action failed.
$this->assertFailedDependency(); // Equivalent to$this->assertStatus(424);
Release notes
You can see the complete list of new features and updates below and the diff between 12.42.0 and 12.43.0 on GitHub. The following release notes are directly from the changelog:
v12.43.0
- [12.x] Add PHPDoc callable types for BusFake methods by @alies-dev in https://github.com/laravel/framework/pull/58070
- Improve type annotations of
$batchIdinBatchabletrait by @markieo1 in https://github.com/laravel/framework/pull/58069 - [12.x] Fix deadlock in cache_locks on cleanup by @jackbayliss in https://github.com/laravel/framework/pull/58071
- feat: implement 'assertFailedDependency' response assertion by @artengin in https://github.com/laravel/framework/pull/58061
- [12.x] Fix using
nullcache store triggering PHP 8.5 deprecation by @jnoordsij in https://github.com/laravel/framework/pull/58074 - [12.x] Fix deprecated usage of passing
nulltoarray_key_existsinAsPivotclass by @jnoordsij in https://github.com/laravel/framework/pull/58073 - [12.x] Simplify clearing resolved instances for
Facadeclasses by @jnoordsij in https://github.com/laravel/framework/pull/58072 - [12.x] Add PHP 8.5 with Herd to passthrough variables in ServeCommand by @bashgeek in https://github.com/laravel/framework/pull/58080
- [12.x] Update actions/checkout v4 to v6 by @jackbayliss in https://github.com/laravel/framework/pull/58078
- [12.x] Let Storage::fake() accept enum as disk name by @bbredewold in https://github.com/laravel/framework/pull/58076
- Improve PHPDoc return type for synchronous HTTP Client methods by @khaled-sadek in https://github.com/laravel/framework/pull/58090
- [12.x] Adjust testCanRetrieveAllFailedJobs by @jackbayliss in https://github.com/laravel/framework/pull/58096
- [12.x] Allow Factory connection method to accept null by @jackbayliss in https://github.com/laravel/framework/pull/58108
- [12.x] Make PendingDispatch::afterResponse conditional by @kenneth-saey in https://github.com/laravel/framework/pull/58099
- [12.x] Add
mergeHiddenandmergeVisiblemethods to Collection class by @mahmoudmohamedramadan in https://github.com/laravel/framework/pull/58110 - Added "SSL error: unexpected eof" message to LostConnectionDetector by @GuidoHendriks in https://github.com/laravel/framework/pull/58113
- [12.x] Update git-auto-commit action by @jackbayliss in https://github.com/laravel/framework/pull/58118
- [12.x] Add tests for Support Uri class by @miladev95 in https://github.com/laravel/framework/pull/58114
- [12.x] Make the Client Response class tappable by @kevinb1989 in https://github.com/laravel/framework/pull/58115
- [12.x] Add missing docblock param in FailedOver event docblocks by @jackbayliss in https://github.com/laravel/framework/pull/58123
- [12.x] Clean up DynamoDbStore by @cosmastech in https://github.com/laravel/framework/pull/58116
- [12.x] Fix: Handle
ParseErrorinhasEvenNumberOfParentheseswhen Xdebug is active by @crynobone in https://github.com/laravel/framework/pull/58128 - [12.x] Fix Password::required() to fail when value is missing by @faisuc in https://github.com/laravel/framework/pull/58125
- [12.x] Add HigherOrderProxy tests (Collection & Tap) by @miladev95 in https://github.com/laravel/framework/pull/58138
- [12.x] Run
ConnectionEstablishedevent on database reconnection by @crynobone in https://github.com/laravel/framework/pull/58136