lundi 25 juillet 2016

Does Laravel's rollback transaction support on Polymorphic relations?

I've got these polymorphic relations:

staff: 
id - integer
name - string

orders:
id - integer
price - integer

photos:
id - integer
path - string
imageable_id - integer
imageable_type - string

And in a controller:

public function example() {

   DB::beginTransaction();

      try {

              $staff = Staff::findOrFail(1);
              $staff->photos()->create([ 'path' => 1 ]);
              $staff->update([ 'path' => 2 ]);
              abort(445);

      } catch( \Exception $e ) {

      \DB::rollback()
   }

}

As expected, the current row must be deleted from photos table, but it still there with path = 2

Do I think in a right away? or It's a misundertanding?



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/29UqkcF
via IFTTT

Aucun commentaire:

Enregistrer un commentaire