I have these polymorphic relationships:
staff:
id - integer
name - string
orders:
id - integer
price - integer
photos:
id - integer
path - string
imageable_id - integer
imageable_type - string
And in the controller:
public function example() {
\DB::beginTransaction();
try {
$staff = Staff::findOrFail(1);
$row = $staff->photos()->create([ 'path' => 1 ]);
$row->path = 2;
$row->save();
abort(445);
} catch( \Exception $e ) {
\DB::rollback()
}
}
As expected, the current row needs to be removed from the photo table, but it still exists with path = 2
Do I think right away? or is this a misunderstanding?
source
share