0
I’m trying to update several lines at once, where I get the information from an array
But so far I have not had much success, despite the attempts, not updating, and returning result 0
the code is currently as follows
public function atualizarEstoqueLocal($input)
{
$resultado = [];
foreach ($input as $result) {
$resultado[] = $this->produto
->where([['id', $result['id']], ['estoque', $result['estoque']]])
->update(array_except($result, 'estoque'));
}
dd($resultado);
return $resultado;
}
would like to get a solution, know how to correct and update.
fajuchem thanks for the answer, really this way seemed more logical and better, but test this way and is returning results all 0 array:3 [ 0 => 0 1 => 0 2 => 0 ]
– Jess
Yes, it returns the update result for each element, because in the example you sent it makes 3 updates, and it can happen that 2 are successfully performed and 1 fails,
– fajuchem