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

Conversation

devajmeireles
Copy link
Contributor

In addition to #55760


The PR #55760 implements the {very useful} #[Context] attribute to interact with Context. However, the addition left out something extremely important when we're talking about Context: the hidden items. I would venture to say that hidden items are used more than common ones.

This PR implements the ability to retrieve hidden items by passing the parameter hidden as true. Thanks to modern PHP's named attributes, we can do something similar to what we find in the docs for things like Livewire:

final class CreateUserAction
{
    public function __construct(#[Context('user', hidden: true)] User $user)
    {
        // ...
    }
}

I thought about creating a second {HiddenContext} attribute, but IMHO it would be too much. A property like hidden serves us very well in this case. Thoughts?

@taylorotwell taylorotwell merged commit b47abb5 into laravel:12.x May 21, 2025
61 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants