Laravel v12.52.0 adds a makeMany() factory method, new withoutAfterMaking() and withoutAfterCreating() factory helpers, atomic writes in the Blade compiler to prevent race conditions, and improved exception traces for closures and standalone functions.
Key highlights include:
- New
makeMany()factory method withoutAfterMaking()andwithoutAfterCreating()factory helperstemporaryUploadUrl()support for local filesystem- Atomic writes in BladeCompiler to prevent race conditions
Mailable::later()delay fix and delay assertions for queued mailablesLazyCollection::random()$preserveKeyssupport- String-based expressions for
selectExpression() - Closures and standalone functions display correctly in exception traces
- Numerous bug fixes and internal improvements
What's New
makeMany() Factory Method
Factories now include a makeMany() method as a complement to createMany(). Where createMany() persists records to the database, makeMany() returns a collection of model instances without saving them — useful when you need multiple in-memory instances for unit tests or transformations:
// Create multiple unsaved instances$users = User::factory()->makeMany(3); // Equivalent longhand$users = User::factory()->count(3)->make();
Pull Request: #58795
withoutAfterMaking() and withoutAfterCreating() Factory Helpers
Two new factory helpers let you skip afterMaking and afterCreating callbacks on a per-call basis. This is useful when a callback sets up relationships or fires side effects that are irrelevant to the current test:
// Skip afterMaking callbacks$user = User::factory()->withoutAfterMaking()->make(); // Skip afterCreating callbacks$user = User::factory()->withoutAfterCreating()->create();
Pull Request: #58794
temporaryUploadUrl() for Local Filesystem
The temporaryUploadUrl() method now works with the local filesystem driver, previously only available for cloud drivers like S3. This makes it possible to use temporaryUploadUrl() in local development and testing environments without needing to swap to a cloud driver:
$url = Storage::disk('local')->temporaryUploadUrl( 'uploads/photo.jpg', now()->addMinutes(30));
Pull Request: #58499
Atomic Writes in BladeCompiler
The Blade compiler now uses atomic writes when caching compiled views and inline component views. Previously, a race condition could occur when multiple processes compiled the same view simultaneously, resulting in corrupted or partially-written cache files. The atomic write approach writes to a temporary file first, then moves it into place, eliminating the race:
Mailable::later() Delay Fix and Delay Assertions
Mailable::later() was not correctly applying the delay to the dispatched SendQueuedMailable job. This is now fixed. A companion PR adds delay support to Mail::assertQueued() so you can assert that a mailable was queued with a specific delay:
Mail::fake(); Mail::to('user@example.com')->later(now()->addMinutes(10), new WelcomeMail()); Mail::assertQueued(WelcomeMail::class, function ($mail) { return $mail->delay->equalTo(now()->addMinutes(10));});
LazyCollection::random() $preserveKeys Support
LazyCollection::random() now accepts a $preserveKeys parameter, matching the behavior already available on Collection::random(). When true, the original keys are preserved in the returned results:
$collection = LazyCollection::make(['a' => 1, 'b' => 2, 'c' => 3, 'd' => 4]); // Preserves original keys$sample = $collection->random(2, preserveKeys: true);// e.g. ['b' => 2, 'd' => 4]
Pull Request: #58791
String-Based Expressions for selectExpression()
selectExpression() on the query builder now accepts raw strings in addition to Expression objects. This reduces boilerplate when you need a single raw expression in a select:
// BeforeDB::table('orders')->selectExpression(DB::raw('SUM(total) as revenue')); // AfterDB::table('orders')->selectExpression('SUM(total) as revenue');
Pull Request: #58753
Closures Display Correctly in Exception Traces
Exception stack traces now correctly display closure and standalone function names instead of showing a generic or empty label. This makes debugging anonymous functions and Closure-based route handlers more readable in error pages and logs.
Pull Request: #58879
Bug Fixes and Improvements
Queue & Async:
- Fix defer callbacks being discarded when using the sync queue (#58745)
Batch::progress()return value cast toint(#58767)
Database & Eloquent:
- Fix empty
Collectionreturned for non-model JSON:API resources (#58752) - Only merge cached casts for accessed attributes (#57627)
- Revert SQL Server column precision checks that caused regressions (#58888)
- MySQL connection string updated to use
--ssl-mode=DISABLEDfor modern clients (#58786)
Testing:
- Add option to opt out of parallel-safe cache prefix isolation (#58801)
Middleware:
- Backport
withMiddlewarechanges from 13.x (#58798)
Type Improvements & Documentation:
- Extensive
@returndocblock fixes and standardization (#58746, #58764, #58774, #58805) - Normalize
Throwabledocblocks to fully-qualified names (#58802) - Various refactors and code style improvements (#58748, #58751, #58777, #58789, #58793, #58818, #58820, #58824, #58825)
Upgrade Notes
No breaking changes are expected for typical applications. The SQL Server column precision revert restores behavior from before v12.51.0 — if you relied on the precision check behavior from that version, review your SQL Server migrations. Review the full changelog for complete details when upgrading.