Skip to content

Commit 6edb1b9

Browse files
committed
Minor fix on BaseRepository
1 parent a8fc71c commit 6edb1b9

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Commands/CriteriaCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function handle()
4848
$content = $this->fileManager->get($this->stubs['criteria']);
4949

5050
$replacements = [
51-
'%namespace%' => "{$this->appNamespace}Criteria\\{$criteria}",
51+
'%namespace%' => "{$this->appNamespace}Criteria",
5252
'%criteriaName%' => $this->criteriaName
5353
];
5454

src/Eloquent/BaseRepository.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,12 @@ protected function manageDeletes(int $id, string $method)
491491
if (($method === 'forceDelete' || $method === 'restore') && !in_array(SoftDeletes::class, class_uses($this->model)))
492492
throw new RepositoryException("Model must implement SoftDeletes Trait to use forceDelete() or restore() method.");
493493

494-
$model = $this->model->withTrashed()->find($id);
494+
if ($method === 'forceDelete' || $method === 'restore')
495+
$model = $this->model->withTrashed();
496+
else
497+
$model = $this->model;
498+
499+
$model = $model->find($id);
495500
$originalModel = clone $model;
496501

497502
$this->resetModel();

0 commit comments

Comments
 (0)