topclaudy / compoships

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

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

Open viiy opened 10 months ago

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

feel free to make a PR with tests