dimanche 30 juin 2019

How to update multiple row at a time in laravel?

I want to update multiple rows at a time. I reform array as follows:

Array
(
    [0] => Array
        (
            [id] => 13
            [up] => 1
            [down] => 2
            [status] => 1
        )

    [1] => Array
        (
            [id] => 14
            [up] => 1
            [down] => 3
            [status] => 1
        )

    [2] => Array
        (
            [id] => 15
            [up] => 1
            [down] => 4
            [status] => 1
        )

)

This array is assigned to $update variable. And trying to update as follows:

      $hierarchyInstance = new Hierarchy;
      Batch::update($hierarchyInstance, $update, 'id');

But I am getting fatal error. Whats wrong in my approach?

I am using laravel 5.7. Thanks in advance.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/322nz0b
via IFTTT

Aucun commentaire:

Enregistrer un commentaire