compoships icon indicating copy to clipboard operation
compoships copied to clipboard

Error when using a column for which the model specifies cast to Enum

Open viiy opened this issue 1 year ago • 1 comments

enum MyModelType: string
{
    case ....

class MyModel extends Model{
...
    protected $casts = [
        'type' => MyModelType::class,
    ];
    
    public function anotherModels(): HasMany
    {
        return $this->hasMany(AnotherModel::class, ['some_field', 'type'], ['some_field', 'type']);
    }
    ....

Object of class MyModelType could not be converted to string

viiy avatar Dec 08 '23 10:12 viiy

feel free to make a PR with tests

jose123v avatar Feb 28 '24 22:02 jose123v