Skip to content

Commit ad0696e

Browse files
committed
[Update] Added massDelete repository method
1 parent c0da4c1 commit ad0696e

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/Contracts/RepositoryInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public function delete(int $id): mixed;
5959

6060
public function deleteWhere(array $where): ?bool;
6161

62+
public function massDelete(): ?bool;
63+
6264
public function forceDelete(int $id): mixed;
6365

6466
public function restore(int $id): mixed;

src/Eloquent/BaseRepository.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,19 @@ public function deleteWhere(array $where): ?bool
366366
return $deleted;
367367
}
368368

369+
public function massDelete(): ?bool
370+
{
371+
$this->applyScope();
372+
373+
$deleted = $this->model->delete();
374+
375+
event(new RepositoryEntityDeleted($this, $this->model->getModel()));
376+
377+
$this->resetModel();
378+
379+
return $deleted;
380+
}
381+
369382
public function forceDelete(int $id): mixed
370383
{
371384
return $this->manageDeletes($id, 'forceDelete');

0 commit comments

Comments
 (0)