Skip to content

Commit

Permalink
feat(Database)!: Delete/forceDelete will always return int (0 for no …
Browse files Browse the repository at this point in the history
…deletion was made)
  • Loading branch information
pionl committed Oct 13, 2022
1 parent 280a545 commit 28b335a
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions src/Database/Queries/AbstractEloquentQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,24 +170,32 @@ protected function findOrFail(string|int $key, array $scopes = [], Closure $cust

/**
* @param Scope[] $scopes
*
* @return TModel
*/
protected function delete(array $scopes = []): mixed
protected function delete(array $scopes = []): int
{
return $this->getQuery($scopes)
$delete = $this->getQuery($scopes)
->delete();

if (is_int($delete)) {
return $delete;
}

return 0;
}

/**
* @param Scope[] $scopes
*
* @return TModel
*/
protected function forceDelete(array $scopes = []): mixed
protected function forceDelete(array $scopes = []): int
{
return $this->getQuery($scopes)
$delete = $this->getQuery($scopes)
->forceDelete();

if (is_int($delete)) {
return $delete;
}

return 0;
}

/**
Expand Down

0 comments on commit 28b335a

Please sign in to comment.