Laravel fill with enum attribute gives error

Solution 1:

Unless you can upgrade the Illuminate libraries being used in your application you don't have the feature of the ability to have the cast get an Enum from a string for you; you will have to pass an Enum. You can get the Enum you need from a string using the from method:

$enum = ComissionamentoVendedor::from($value);

If you are not sure if this value is actually a valid value for the Enum you can use the tryFrom method:

$enum = CommissionamentoVendedor::tryFrom($value) ?? $defaultEnum;

PHP.net Manual - Language Reference - Enumerations - Backed enumerations

Github - Laravel Framework - Commit - [8.x] Enum casts accept backed values committed on Nov 15, 2021