topclaudy / compoships

Multi-columns relationships for Laravel's Eloquent ORM
MIT License
1.12k stars 132 forks source link

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

Open viiy opened 11 months ago

viiy commented 11 months ago
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

jose123v commented 9 months ago

feel free to make a PR with tests