1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Prevent duplicate deletions

This commit is contained in:
Hillel Coren 2016-03-23 15:02:53 +02:00
parent 4eae70400e
commit 39f426e352

View File

@ -20,6 +20,10 @@ class BaseRepository
public function archive($entity) public function archive($entity)
{ {
if ($entity->trashed()) {
return;
}
$entity->delete(); $entity->delete();
$className = $this->getEventClass($entity, 'Archived'); $className = $this->getEventClass($entity, 'Archived');
@ -31,6 +35,10 @@ class BaseRepository
public function restore($entity) public function restore($entity)
{ {
if ( ! $entity->trashed()) {
return;
}
$fromDeleted = false; $fromDeleted = false;
$entity->restore(); $entity->restore();
@ -49,6 +57,10 @@ class BaseRepository
public function delete($entity) public function delete($entity)
{ {
if ($entity->is_deleted) {
return;
}
$entity->is_deleted = true; $entity->is_deleted = true;
$entity->save(); $entity->save();