Skip to content

Commit

Permalink
Delete attachement with same key
Browse files Browse the repository at this point in the history
  • Loading branch information
gabsource committed Mar 11, 2019
1 parent d55d429 commit 73901d0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Attachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ public static function attach($uuid, $model, $options = [])

$attachment->fill($options);

if ($found = $model->attachments()->where('key', '=', $attachment->key)->first()) {
$found->delete();
}

return $attachment->model()->associate($model)->save() ? $attachment : null;
}

Expand Down

0 comments on commit 73901d0

Please sign in to comment.