Skip to content

Commit

Permalink
feat(service): create soft delete methods
Browse files Browse the repository at this point in the history
  • Loading branch information
txsoura committed May 9, 2021
1 parent 2bf687a commit 36019b7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Services/Traits/SoftDeleteMethodsService.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Txsoura\Core\Services\Traits;

trait SoftDeleteMethodsService
{
public function forceDestroy($id)
{
$model = $this->model()::withTrashed()
->whereId($id)
->firstOrFail();
$model->forceDelete();
}

public function restore($id)
{
$model = $this->model()::withTrased()
->whereId($id)
->firstOrFail();
$model->restore();
}
}

0 comments on commit 36019b7

Please sign in to comment.