Skip to content
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

[10.x] Add Conditionable in enum rule #50257

Merged
merged 1 commit into from
Feb 26, 2024
Merged

[10.x] Add Conditionable in enum rule #50257

merged 1 commit into from
Feb 26, 2024

Conversation

michaelnabil230
Copy link
Contributor

This PR adds Conditionable trait to Enum rule.

How to use:

Rule::enum(PostStatus::class)
    ->when(
        auth()->user()->is_admin,
        fn ($rule) => $rule->only([PostStatus::APPROVED]),
        fn ($rule) => $rule->only([PostStatus::PADDING]),
    );

@taylorotwell taylorotwell merged commit 9fde814 into laravel:10.x Feb 26, 2024
26 checks passed
@michaelnabil230 michaelnabil230 deleted the rule branch February 26, 2024 16:30
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