Call to undefined method Illuminate\Database\Eloquent\Relations\BelongsToMany::getOwnerKeyName()
Hi there! Created a simple BelgonsToMany relationship like in Laravel Documentation(https://laravel.com/docs/10.x/eloquent-relationships#many-to-many-defining-the-inverse-of-the-relationship) and I've got the following error:
I've used the example from the FIlament documentation for creating a Select:
https://flareapp.io/share/Lm8MOMpP
Thank you!
Flare
Call to undefined method Illuminate\Database\Eloquent\Relations\BelongsToMany::getOwnerKeyName() - The error occurred at http://disponibilitati.test/admin/apartments/create
Laravel - The PHP Framework For Web Artisans
Laravel is a PHP web application framework with expressive, elegant syntax. We’ve already laid the foundation — freeing you to create without sweating the small things.
12 Replies
guess you called the value before "getOwnerKeyName()" as a method, not as a value?
I am guessing it was a user.. call user->getOwnerKeyName()
calling it as a method will return the relation, not the instance
I did not called it. The only place where I used the relationship is in this piece of code:
have you pinpointed what line throws the error?
GitHub
filament/packages/forms/src/Components/Select.php at 633ea6f739ced1...
Admin panel, form builder and table builder for Laravel. Built with the TALL stack. Designed for humans. - filament/packages/forms/src/Components/Select.php at 633ea6f739ced12b4dd4d9403ce5bc66efa1e...
Thsi one
and your relations are? so I can try to replicate it
One moment
getting the same error now
@alexmanase I do not know the fix, seems like a bug.. but you could use this workaround:
or the other way around with projects, does not make a difference
Thanks! I know that, but I need to create a new relationship model from the select.
Like this.
I'll make an issue to the Filament repo
Thanks for your help.
I don’t think you can use a many to many on a select without making it multiple.
Might also need 'withPivot' on your relationships
GitHub
Call to undefined method Illuminate\Database\Eloquent\Relations\Bel...
Package filament/filament Package Version ^2.0 Laravel Version ^10.10 Livewire Version ^2.12 PHP Version 8.2.7 Problem description When I try to use a select for a resource using BelongsToMany rela...
Thanks!