Astrotomic / laravel-translatable

A Laravel package for multilingual models
https://docs.astrotomic.info/laravel-translatable/
MIT License
1.22k stars 152 forks source link

Call to a member function firstWhere() on array #417

Closed cheeeasy2501 closed 4 days ago

cheeeasy2501 commented 4 days ago

Describe the bug When I fill the database via seeder and call->translateOrNew($locale) on the model, I get the error "Call to a member function firstWhere() on array"

To Reproduce

Expected behavior There is no error and everything works. I am a model as expected

Screenshots bug-translatable

Versions (please complete the following information)

Additional context Add any other context about the problem here.

Exception "Call to a member function firstWhere() on array"

cheeeasy2501 commented 4 days ago

I fixed this with cast 'translations' => AsCollection::class, but decided to report it anyway if anyone has the same problem.

cheeeasy2501 commented 4 days ago

Sorry, this is my file. I have overwritten the translations entry as an array. Closing the ticket ;)