If you want to update an existing pivot record on the table, use updateExistingPivot
instead of syncWithPivotValues
.
1// Migrations 2Schema::create('role_user', function ($table) { 3 $table->unsignedId('user_id'); 4 $table->unsignedId('role_id'); 5 $table->timestamp('assigned_at'); 6}) 7 8// first param for the record id 9// second param for the pivot records10$user->roles()->updateExistingPivot(11 $id, ['assigned_at' => now()],12);
Tip given by @sky_0xs