News

Arr::from() Method in Laravel 12.14

Published
Arr::from() Method in Laravel 12.14 image

Release updates

Never miss a Laravel release

Get an email whenever a new Laravel release lands.

The Laravel team released v12.14.0, which includes a new Arr::from() method, a currentlyResolving() container method, new "except" Context methods, and more:

Arr::from() Method

Sergey Danilchenko contributed an Arr::from() method to get the underlying array of items from the given argument:

use Illuminate\Support\Arr;
 
Arr::from(collect(['name' => 'Laravel'])); // ['name' => 'Laravel']
Arr::from($jsonable); // Decodes the object data via `Jsonable` as an array
Arr::from($arrayable); // Returns array via the object `toArray()` method

See Pull Request #55715 for details.

New Context Methods

Volodya Kurshudyan contributed except() and exceptHidden() methods to the Context class to retrieve all values except the specified keys:

Context::add('user_id', 42);
Context::add('request_id', 'req-abc123');
Context::add('ip_address', '192.168.0.1');
Context::add('sensitive_token', 'secret');
 
$logData = Context::except(['sensitive_token']);
 
// Result:
[
'user_id' => 42,
'request_id' => 'req-abc123',
'ip_address' => '192.168.0.1',
]

See Pull Request #55692 for details.

Container currentlyResolving utility method

Justin Seliga contributed a currentlyResolving that returns the binding that the container is currently resolving:

#[Attribute(Attribute::TARGET_PARAMETER)]
class RegisteredFor implements ContextualAttribute
{
public static function resolve(self $attribute, Container $container): array
{
$resolving = $container->currentlyResolving(); // Production::class
 
return resolve(Registrar::class)->for($resolving);
}
}

See Pull Request #55684 for details.

Release notes

You can see the complete list of new features and updates below and the diff between 12.13.0 and 12.14.0 on GitHub. The following release notes are directly from the changelog:

v12.14.0

Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article