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

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

Open
viiy opened this issue Dec 8, 2023 · 1 comment
Open

Comments

@viiy
Copy link

viiy commented Dec 8, 2023

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
Copy link

feel free to make a PR with tests

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