BenSampo / laravel-enum

Simple, extensible and powerful enumeration implementation for Laravel.
https://sampo.co.uk/blog/using-enums-in-laravel
MIT License
1.99k stars 163 forks source link

validateEnumValue does not exist #326

Closed Livijn closed 1 year ago

Livijn commented 1 year ago

When I updated to 6.4.0 my tests are throwing exceptions:

validateEnumValue does not exist

Pretty sure it's related to this: https://github.com/BenSampo/laravel-enum/pull/324

spawnia commented 1 year ago

Summoning @shaffe-fr, would you happen to have an idea how to fix this?

shaffe-fr commented 1 year ago

Hey @Livijn, can you show us the failing test? Thanks

Livijn commented 1 year ago

Well, it's pretty basic.

Controller:

    public function destroy(Request $request, $slug)
    {
        $request->validate([
            'delete_reason' => 'required|enum_value:'.AdDeleteReason::class.',false',
        ]);
    }

Test:

        $this->delete(route('ads.destroy', ['slug' => $ad->slug]), ['delete_reason' => AdDeleteReason::Other])
            ->assertSuccessful();
shaffe-fr commented 1 year ago

Do you register EnumServiceProvider manually?

Livijn commented 1 year ago

No, and I can see the make:enum command registered if I use php artisan list.

shaffe-fr commented 1 year ago

@Livijn Can you try #327?

Livijn commented 1 year ago

It works! :)

spawnia commented 1 year ago

Fixed with v6.4.1.

shaffe-fr commented 1 year ago

Great, sorry for the hiccup!