How to have BelongsToMany with multiple relations in the backend?

The first core modification works (I can now see existing IDs on the list) but it just updates the existing one when adding a new one. However I don’t have the other line in modules/backend/behaviors/relationcontroller/HasPivotMode.php.

OK I’ll wait for your update :slight_smile:

Ok, this has been fixed in v3.6.19. The following has been added to the documentation.

Allowing Duplicate Relations

In some cases you may want to associate the same relationship twice or more, using different pivot data for each attached record. Below is an example that shows a database table structure that has an incrementing primary key on the join table instead of a composed primary key.

Schema::create('role_user', function($table) {

A custom pivotModel must be used for this configuration, and the pivotKey property is set to the incrementing column name (id).

public $belongsToMany = [
    'roles' => [
        'pivotModel' => \Acme\Blog\Models\UserRolePivot::class,
        'pivotKey' => 'id'

The pivot model definition should set the $incrementing property to true to enable the incrementing primary key.

class UserRolePivot extends \October\Rain\Database\Pivot
    public $incrementing = true;

Hi, so cool! Thanks. How long till this version is available on update channel?
We just renewed the license that expired months ago.

Hi @daft,
is there a way to upgrade without the UI update channel?

This has been released in v3.6.19 today.

Yes, partners have access to the development repo in GitHub. Send us an email with your GitHub username and we can add you to it.

1 Like