-
Notifications
You must be signed in to change notification settings - Fork 920
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
Problems with many-to-many relation fields. #90
Comments
Hi Oleh, Can you also try declaring the field with: 'model' => 'App\Models\Genre', instead of 'model' => Genre::class, and tell me if it fixes your issue? (assuming your Genre model is in a Models folder, otherwise just Cheers! |
Thanks for so fast reaction! |
Hmm... I just tried it on fresh installation and it works for me, throws no errors. So it's most likely an implementation problem or a very very niche issue. From the error you gave me it seems like the relationship might not be properly defined. Eloquent tries to save the multiple genre ids in the albums table, which I bet is wrong.
public function genres()
{
return $this->belongsToMany('App\Models\Genres', 'albums')->withTimestamps();
} (most likely not the issue, but worth the shot)
Cheers! |
Hi @Ole-Gi , Are you still having this issue or have you abandoned? Thanks, cheers! |
P.S. I'll go ahead and close this issue so we don't clog the section. Feel free to open it again if you encounter problems or comment if you have follow-ups. |
Hi folks, I have encountered problem while creating/updating entity with many-to-many relation.
I have a field configured like this:
Class has relation:
But when I'm trying to create/update User entity I get the error
I think a problem is because it tries to save fields for many-to-many relation and falls on the array.
I found solution: to add filtration in trait Create - to unset all relational fields before
Maybe I'm doing something wrong and there is an error in field configuration.
Please help.
Regards, Oleh.
The text was updated successfully, but these errors were encountered: