This forum has moved to a new location and is in read-only mode. Please visit to access the new location.


Hi everyone, I have an issue when using $belongToMany self relationship as describes on below:

I had a model named Workshops. The Workshop will be "tag on" one or many other workshops. There will be a table named workshops_tagons to keep relationship, it has 2 columns workshop_id and tagon_id (mean the tagged workshops_id). I defined the relation as below on Workshops model:

public $belongsToMany = [
'tagons' => [ 'MyApp\MyPlugin\Models\Workshops', 'table' => 'myapp_myplugin_workshops_tagons', ] ];

When create Workshop i have a tab to load all workshops on to there, and user can check to select "tagon" workshops for the creating workshop then save. When saved, the was no error occur but the issue is: on the table workshops_tagons the column workshop_id was updated with the id of the "tagon" workshops id, and the tagon_id was updated as 0.

The expected should be: workshop_id should be updated with the id of creating workshop and tagon_id should be updated with the "tagon" workshops id.

Please help me if anyone have experienced on that case, much appreciate.

Last updated


I´m interested to know if this was resolved. I´m having troubles with a basic User model with a HasMany relationship (friends) to itself.

1-2 of 2

You cannot edit posts or make replies: the forum has moved to