8000 [12.x] Allowing `Context` Attribute to Interact with Hidden by devajmeireles · Pull Request #55799 · laravel/framework · GitHub
[go: up one dir, main page]

Skip to content

[12.x] Allowing Context Attribute to Interact with Hidden #55799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added hidden attribute to Context class, updated resolve method
  • Loading branch information
devajmeireles committed May 21, 2025
commit 556ff26c716c5f5d0c6f85ff77eb66824f3aa8c5
9 changes: 7 additions & 2 deletions src/Illuminate/Container/Attributes/Context.php
7967
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Context implements ContextualAttribute
/**
* Create a new attribute instance.
*/
public function __construct(public string $key, public mixed $default = null)
public function __construct(public string $key, public mixed $default = null, public bool $hidden = false)
{
}

Expand All @@ -26,6 +26,11 @@ public function __construct(public string $key, public mixed $default = null)
*/
public static function resolve(self $attribute, Container $container): mixed
{
return $container->make(Repository::class)->get($attribute->key, $attribute->default);
$repository = $container->make(Repository::class);

return match ($attribute->hidden) {
true => $repository->getHidden($attribute->key, $attribute->default),
false => $repository->get($attribute->key, $attribute->default),
};
}
}
0