Skip to content

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
@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