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

nvloi21217833
nvloi21217833

Hi I can find a way to insert a new model like:


$flight = new Flight;
$flight->name = 'Sydney to Canberra';
$flight->save();

But my model have "$belongsToMany" relation with other model and it have a pivot. I want to ask if i can use basic inserts above or i must use DB to insert to table.


public $belongsToMany = [
        'model1' => [
            'abc\def\Models\model1',
            'table' => 'abc_def_model1_model2',
            'key' => 'model1_id',
            'otherKey' => 'model2_id',
            'pivot' => ['score']
        ]
];

Thanks

Last updated

1-1 of 1

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.