yaddly's avatar

When method on Enum Validation Rule Throws Undefined Method Error

Hi Laracons, I have recently updated my laravel framework to version 10.46.0. However, when I try to use when method to conditionally modify the Enum validation rule as below, I get undefined method error on when

Rule::enum(ServerStatus::class)
    ->when(
        Auth::user()->isAdmin(),
        fn ($rule) => $rule->only(...),
        fn ($rule) => $rule->only(...),
    );

What could I be doing wrong? I would appreciate any help you can afford me. I have already tried clearing the cache, config, clear-compiled and ran composer dump-autoload -o, but nothing is working.

0 likes
3 replies
yaddly's avatar

@s4muel Hi, thank you for your insightful pointers. Unfortunately, I have setup everything the right way but it is not working for me 😭🥹😢🥲

yaddly's avatar
yaddly
OP
Best Answer
Level 2

Laravel just released a patch to version 10.46.0 as version 10.47.0, everything is working as expected after upgrading the framework again.

Please or to participate in this conversation.