Sync with Collection ManyToMany with additional pivot column
Bug Report
Q | A |
---|---|
PHP version | 7.3.14 |
Package version | 1.3.0, Eventually 1.0.7 |
Framework | Laravel |
Framework version | 6.13.1 |
Actual Behaviour
Given we have two models - Game and Player and pivot table with additional columns e.g.
$table->unsignedBigInteger('game_id');
$table->unsignedBigInteger('player_id');
$table->string('level');
When syncing many to many relation with collection e.g.
$players = collect([2 => ['level' => 6]]);
Game::find(1)->players()->sync($players);
Pivot table is saved properly, but Ledger generates malformed data in pivot column:
{"relation": "players", "properties": {"2": {"game_id": 1, "player_id": {"level": 6}}}}
Expected Behaviour
Generated data in pivot to be:
{"relation": "players", "properties": [{"level": 6, "game_id": 1, "player_id": 2}]}