#[Tinker] Access pivot table data with 3 IDs
13 messages · Page 1 of 1 (latest)
Attach will just attach a row, sync will remove anything not included in the array and then add the array - so it depends what you want to accomplish. I'm not sure about your relationships, but I think something like this might do what you're looking for -
$game->platform()->attach($platformId, ['region_id' => $regionId, 'game_release_date' => $gameReleaseDate]);
It talks about adding intimediary table columns, which is what you're doing.
I just adjusted my code example based on it.
Can you share the code you used to do that?
It looks like you didn't provide the region_id like in my example above, from the error.
It inserted?
No, that was pre-existing data.
Do you have a class for the pivot table?
You might need to make region_id mass assignable.
👍