AttributeIlluminate\Container\Attributes\Context
#[Context]
In the Container group, #[Context] applies this configuration to the target Laravel element. It accepts 3 configuration parameters.
Available since
Laravel 13.0
Targets
parameter
Parameters
$keystringKey used to resolve the value. Expected type: string.
$defaultmixedFallback value when no result is found. Expected type: mixed.
$hiddenboolDefines the "hidden" value used by the attribute. Expected type: bool.
Practical usage
use Illuminate\Container\Attributes\Context;
class ReportsController
{
public function __invoke(#[Context('value', null, false)] mixed $value): array
{
return ['status' => 'ok'];
}
}