Explore the latest innovations, expert analysis, and industry updates in tech news. Stay informed, discover emerging trends, and enhance your knowledge with every update.

Laravel's latest release, v12.4.0, introduces several valuable features aimed at improving query handling, migration management, and testing capabilities. Among the highlights are the Query Builder pipe() method, a mechanism for skipping migrations based on conditions, a new Arr::sole() function, and several other helpful improvements.
Contributor: Tim MacDonald
One of the standout additions is the pipe() method, now available in both the query builder and Eloquent. This new function operates similarly to the Collection::pipe() method, allowing developers to apply operations in a pipeline and streamline their queries.
$records = DB::query()
->from('...')
// other query modifications
->tap(new TappableScope) // returns the query object
->pipe(new ActionScope); // executes and returns the result
Laravel 12.4 introduces the ability to conditionally skip migrations. A new shouldRun() method has been added, enabling you to determine whether a migration should run based on custom conditions, such as whether a feature is active.
return new class extends Migration
{
public function shouldRun()
{
return Feature::active(Flights::class);
}
// other migration logic
}
A new Arr::sole() method joins the array helper family, mimicking the behavior of the Collection::sole() method. It ensures that you retrieve a single element from an array only if it is the sole item. It throws exceptions when there are multiple matches or no matches at all.
Arr::sole(['foo']); // Returns "foo"
// Throws ItemNotFoundException if the item isn't found
Arr::sole(['foo'], fn (string $value) => $value === 'baz');
// Throws MultipleItemsFoundException for multiple matching items
Arr::sole(['baz', 'foo', 'baz'], fn (string $value) => $value === 'baz');
Laravel 12.4 now includes the listenersPushed() method for asserting that a queue listener was triggered during testing. This enhancement improves the testing experience by providing an easy way to check whether an event was handled.
Queue::fake();
event(new SomeEvent(value: 'look, a value!'));
$this->assertCount(
1,
Queue::listenersPushed(
SomeEventListener::class,
fn (SomeEvent $event) => $event->value === 'look, a value!'
)
);
A new Model::except() method allows you to retrieve a model's attributes while excluding specific fields, serving as the reverse of the only() method.
$user->except('id', 'email');
This new method simplifies testing by asserting that a given block of code does not throw an exception.
$this->assertDoesntThrow(fn () => (new ProcessOrder)->execute());
Laravel now supports the whereNull() and whereNotNull() methods in AssertableJson instances, allowing for easy verification of null values in JSON responses.
fn (AssertableJson $json) => $json->whereNull('error')
// Example from framework tests
$assert = AssertableJson::fromArray([
'bar' => 'value',
]);
$this->expectException(AssertionFailedError::class);
$this->expectExceptionMessage('Property [bar] should be null.');
$assert->whereNull('bar');
With these updates, Laravel 12.4 continues to enhance the framework's flexibility, improve testing capabilities, and streamline database operations, making it an even more powerful tool for developers.

API-First Development Reshapes Modern Web Platforms

Distributed Databases Power Next Generation Applications

Edge Computing Expands Modern Web and App Infrastructure

Modern UX Trends Transform Web and App Interfaces

Platform Engineering Drives Next-Gen Cloud & DevOps

Zero-Trust Security Shapes Modern Web and App Platforms