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

Laravel v11.33.0+ in-compatible with TransformsEnums::enums() #108

Closed
Saifallak opened this issue Nov 20, 2024 · 2 comments
Closed

Laravel v11.33.0+ in-compatible with TransformsEnums::enums() #108

Saifallak opened this issue Nov 20, 2024 · 2 comments

Comments

@Saifallak
Copy link

getting this error when using use TransformsEnums;

 Declaration of Illuminate\Http\Request::enums($key, $enumClass) must be compatible with Spatie\Enum\Laravel\Http\Requests\TransformsEnums::enums(): array
@Saifallak
Copy link
Author

related to this laravel/framework#53540

@Saifallak Saifallak changed the title Declaration of Illuminate\Http\Request::enums($key, $enumClass) must be compatible with Spatie\Enum\Laravel\Http\Requests\TransformsEnums::enums(): array Laravel v11.33.0 in-compatible with TransformsEnums::enums() Nov 20, 2024
@Saifallak Saifallak changed the title Laravel v11.33.0 in-compatible with TransformsEnums::enums() Laravel v11.33.0+ in-compatible with TransformsEnums::enums() Nov 20, 2024
@boserup
Copy link

boserup commented Nov 25, 2024

For those interested, as a fix (whilst transitioning away from Spatie enums in our Laravel project), we implemented a custom trait:

/**
 * Fix enum method collision with Laravel v11.33.0+
 * @link https://github.com/spatie/laravel-enum/issues/108
 *
 * @method void transformEnums(array $transformations)
 */
trait TransformsLegacyEnums
{
    protected function passedValidation()
    {
        $this->transformEnums($this->legacyEnums());
    }

    abstract public function legacyEnums(): array;
}

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

No branches or pull requests

2 participants