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

acquaintsoft logo
Acquaint Softtech

Hire Laravel developers with AI expertise at $20/hr. Get started in 48 hours.

Visit Acquaint Softtech

The latest

View all →
Laravel monitoring that doesn't bill you by your traffic image

Laravel monitoring that doesn't bill you by your traffic

Read article
Mock PHP Classes in Tests With the Double Library image

Mock PHP Classes in Tests With the Double Library

Read article
Laravel Discount: Coupon Codes, Usage Limits, and Stacking image

Laravel Discount: Coupon Codes, Usage Limits, and Stacking

Read article
Laravel Truss: Live Interactive Database ER Diagrams image

Laravel Truss: Live Interactive Database ER Diagrams

Read article
Laravel artisan dev: Run Server, Queue, Logs, and Vite image

Laravel artisan dev: Run Server, Queue, Logs, and Vite

Read article
Validate and Convert HEIC Images in Laravel image

Validate and Convert HEIC Images in Laravel

Read article