Sie nur nur mit einem Schleifen-Anweisung, da es updateExistingPivot Funktion aktualisieren können eindimensional params akzeptieren, finden Sie in der Kernfunktion für Laravel 5.3.
File: yoursite\vendor\laravel\framework\src\Illuminate\Database\Eloquent\Relations\BelongsToMany.php
Funktion: updateExistingPivot
public function updateExistingPivot($id, array $attributes, $touch = true)
{
if (in_array($this->updatedAt(), $this->pivotColumns)) {
$attributes = $this->setTimestampsOnAttach($attributes, true);
}
$updated = $this->newPivotStatementForId($id)->update($attributes);
if ($touch) {
$this->touchIfTouching();
}
return $updated;
}
Also, sollten Sie den einfachen Prozess folgen:
$step = Step::find($stepId);
foreach(yourDataList as $youData){
$step->contacts()->updateExistingPivot($youData->contract_id, [
'completed' => true,
'run_at' => \Carbon\Carbon::now()->toDateTimeString()
]);
}
Nicht sicher, aber versuchen Sie es eine Reihe stellen mit ids – apelsinka223
Ich habe versucht, und es didn 't Arbeit :( – Victor
Vielleicht ist es ein Fehler, es scheint, Arbeit zu sein http://stackoverflow.com/a/30756967/4581725 – apelsinka223