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
{
}
/**
- * The the user that performed the deletion.
+ * Get the user that performed the deletion.
*/
public function deleter(): BelongsTo
{
{
$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("/settings/recycle-bin/{$this->id}/" . ltrim($path, '/'));
}