# Arr::from() Method
12.14 新增 Arr::from(),可從多種資料結構取得 array of items
<?php
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
# New Context Methods
12.14 新增 except() & exceptHidden() context method
<?php
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',
]
# Container currentlyResolving utility method
12.14 新增 currentlyResolving method,return 當前 container 正在 resolve 的對象
<?php
#[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);
}
}