Skip to content

Commit

Permalink
Revert "optimization"
Browse files Browse the repository at this point in the history
This reverts commit d68d752.
  • Loading branch information
ajaycalicut17 committed May 1, 2024
1 parent d68d752 commit 4652a4a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/Listeners/DeletedFromTrash.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@ public function __construct()
//
}

public function handle(DeleteFromTrash $event): void
/**
* Handle the event.
*/
public function handle(DeleteFromTrash $deleteFromTrash): void
{
$event->model->trashable()->forceDelete();
$deleteFromTrash->model->trashable()->forceDelete();
}
}
4 changes: 2 additions & 2 deletions src/Listeners/RestoredFromTrash.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public function __construct()
/**
* Handle the event.
*/
public function handle(RestoreFromTrash $event): void
public function handle(RestoreFromTrash $restoreFromTrash): void
{
$event->model->trashable()->restore();
$restoreFromTrash->model->trashable()->restore();
}
}
12 changes: 7 additions & 5 deletions src/Models/Trash.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ public function trashable(): MorphTo
}

/**
* Restore the associated model from the trash.
* restore associated model form trash.
*/
public function restoreFromTrash(): self
public function restoreFromTrash(): Trash
{
$this->deleteQuietly();

Expand All @@ -55,11 +55,13 @@ public function deleteFromTrash(): ?bool
}

/**
* Delete all trashed models and their associated models.
* delete all trashed model and associated model.
*/
public static function emptyTrash(): void
public static function emptyTrash(): LazyCollection
{
static::cursor()->each(fn (Trash $trash) => $trash->delete());
return static::cursor()->each(function ($each) {

Check failure on line 62 in src/Models/Trash.php

View workflow job for this annotation

GitHub Actions / phpstan

Call to an undefined static method Ajaycalicut17\LaravelTrash\Models\Trash::cursor().
$each->delete();
});
}

/**
Expand Down

0 comments on commit 4652a4a

Please sign in to comment.