1 <?php namespace BookStack\Entities;
3 use BookStack\Auth\User;
4 use Illuminate\Database\Eloquent\Model;
5 use Illuminate\Database\Eloquent\Relations\BelongsTo;
6 use Illuminate\Database\Eloquent\Relations\MorphTo;
8 class Deletion extends Model
12 * Get the related deletable record.
14 public function deletable(): MorphTo
16 return $this->morphTo('deletable')->withTrashed();
20 * The the user that performed the deletion.
22 public function deleter(): BelongsTo
24 return $this->belongsTo(User::class, 'deleted_by');
28 * Create a new deletion record for the provided entity.
30 public static function createForEntity(Entity $entity): Deletion
32 $record = (new self())->forceFill([
33 'deleted_by' => user()->id,
34 'deletable_type' => $entity->getMorphClass(),
35 'deletable_id' => $entity->id,