Never Miss a Laravel Release 🚀
The Laravel team released version 12.42, featuring HTTP client request attributes, support for Enums in Translator replacements, schema builder index methods, and more.
HTTP Client Request Attributes
Luke Kuzmish contributed a withAttributes() method to define attribute data on a PendingRequest instance. You can then retrieve it later using the attributes() method:
$response = Http::withAttributes(['name' => 'first']) ->get('https://example.com/test'); $response->attributes(); // ['name' => 'first']
See Pull Request #58038 for implementation details and discussion.
Support for Enums in Translator Replacements
Hossein Hosni contributed an update that supports Enums in Translator replacements:
$t = new Translator($loader, 'en');$t->get('string_backed_enum', ['month' => Month::February]);// Laravel 12 was released in :month 2025// Laravel 12 was released in February 2025
See Pull Request #58048 for implementation details.
Schema Builder Index Checks
Jack Bayliss contributed whenTableHasIndex and whenTableDoesntHaveIndex methods to run code based on whether a table has an index or not:
use Illuminate\Support\Facades\Schema; // Beforepublic function up(): void{ if (! Schema::hasIndex('product', 'name')) { Schema::table('product', function (Blueprint $table) { $table->index('name', 'index_name'); }); }} // Afterpublic function up(): void{ Schema::whenTableHasIndex('product', 'name', function (Blueprint $table) { $table->index('name', 'index_name'); }); // You can also pass the index type... Schema::whenTableDoesntHaveIndex('product', 'name', function (Blueprint $table) { $table->index('name', 'index_name'); }, 'unique');}
See Pull Request #58005 for implementation details.
Release notes
You can see the complete list of new features and updates below and the diff between 12.41.0 and 12.42.0 on GitHub. The following release notes are directly from the changelog:
v12.42.0
- [12.x] Improve
Context::scope()return type by @cosmastech in https://github.com/laravel/framework/pull/58012 - [12.x] Allow float values in duration helpers for CarbonInterval by @SanderMuller in https://github.com/laravel/framework/pull/58006
- Add whenTableHasIndex and whenTableDoesntHaveIndex to Builder by @jackbayliss in https://github.com/laravel/framework/pull/58005
- [12.x] Add commandFileFinder method and exclude test files from command discovery by @davidhemphill in https://github.com/laravel/framework/pull/58017
- [12.x] Fix Cache spy not working with memoized cache by @faisuc in https://github.com/laravel/framework/pull/57996
- Respect --quiet and --silent in queue:work command by @MatusBoa in https://github.com/laravel/framework/pull/58024
- [12.x] Improve Blueprint docblocks with concrete value ranges for integer and text columns by @nguyentranchung in https://github.com/laravel/framework/pull/58019
- [12.x] Modernize typecasting by @cosmastech in https://github.com/laravel/framework/pull/58037
- [12.x] Fix
requiredandsometimesvalidation ofPasswordrule by @mrvipchien in https://github.com/laravel/framework/pull/58034 - [12.x] Add support as a depdency for container by @adrum in https://github.com/laravel/framework/pull/58026
- fix autoloading StringableObjectStub class in tests/Support/SupportStringableTest.php by @angus-mcritchie in https://github.com/laravel/framework/pull/58030
- [12.x] Remove calls to
optional()by @cosmastech in https://github.com/laravel/framework/pull/58027 - [12.x] Add
newRequest()to Pool and Batch by @cosmastech in https://github.com/laravel/framework/pull/58038 - [12.x] Align Listener docblock and add unit test for query shape by @miladev95 in https://github.com/laravel/framework/pull/58040
- [12.x] feat: add pre-migration hook when setting up databases in parallel tests by @philipheimboeck in https://github.com/laravel/framework/pull/58011
- [12.x] Supports PHPUnit 12.5 by @crynobone in https://github.com/laravel/framework/pull/58042
- [12.x] Add support for Enums in Translator replacements by @hosni in https://github.com/laravel/framework/pull/58048
- [12.x] Fix
PendingRequest@pool()&&batch()concurrency by @cosmastech in https://github.com/laravel/framework/pull/57973 - [12.x] New
illuminate/reflectionscomponent fromilluminate/supportby @crynobone in https://github.com/laravel/framework/pull/58052 - Make queue commands' option descriptions more consistent by @jasonlbeggs in https://github.com/laravel/framework/pull/58058
- [12.x] Add LICENSE, auto close for PRs and
.gitattributestoilluminate/reflectionby @crynobone in https://github.com/laravel/framework/pull/58055 - [12.x]
PendingRequest@withRequestContext()by @cosmastech in https://github.com/laravel/framework/pull/58054