X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/1c43602f4bed60a84f47735ca8bc4a399018e013..refs/pull/3391/head:/app/Entities/Models/Deletion.php diff --git a/app/Entities/Models/Deletion.php b/app/Entities/Models/Deletion.php index 764c4a1e3..181c9c580 100644 --- a/app/Entities/Models/Deletion.php +++ b/app/Entities/Models/Deletion.php @@ -3,13 +3,14 @@ namespace BookStack\Entities\Models; use BookStack\Auth\User; +use BookStack\Interfaces\Deletable; use BookStack\Interfaces\Loggable; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\MorphTo; /** - * @property Model deletable + * @property Deletable $deletable */ class Deletion extends Model implements Loggable { @@ -22,7 +23,7 @@ class Deletion extends Model implements Loggable } /** - * The the user that performed the deletion. + * Get the user that performed the deletion. */ public function deleter(): BelongsTo { @@ -32,7 +33,7 @@ class Deletion extends Model implements Loggable /** * Create a new deletion record for the provided entity. */ - public static function createForEntity(Entity $entity): Deletion + public static function createForEntity(Entity $entity): self { $record = (new self())->forceFill([ 'deleted_by' => user()->id, @@ -48,13 +49,17 @@ class Deletion extends Model implements Loggable { $deletable = $this->deletable()->first(); - return "Deletion ({$this->id}) for {$deletable->getType()} ({$deletable->id}) {$deletable->name}"; + if ($deletable instanceof Entity) { + return "Deletion ({$this->id}) for {$deletable->getType()} ({$deletable->id}) {$deletable->name}"; + } + + return "Deletion ({$this->id})"; } /** * Get a URL for this specific deletion. */ - public function getUrl($path): string + public function getUrl(string $path = 'restore'): string { return url("/http/source.bookstackapp.com/settings/recycle-bin/{$this->id}/" . ltrim($path, '/')); }