*/ protected $dispatchesEvents = [ 'created' => DumpCreated::class, 'deleted' => DumpDeleted::class, 'updated' => DumpUpdated::class, ]; /** * The attributes that are mass assignable. * * @var list */ protected $fillable = [ Dump::ATTRIBUTE_PATH, ]; /** * The accessors to append to the model's array form. * * @var list */ protected $appends = [ Dump::ATTRIBUTE_LINK, ]; /** * The link of the dump. */ protected function getLinkAttribute(): ?string { if ($this->hasAttribute($this->getRouteKeyName()) && $this->exists) { return route('dump.show', $this); } return null; } public function getName(): string { return $this->path; } public function getSubtitle(): string { return $this->getName(); } /** * Get the available safe dumps. * * @return string[] */ public static function safeDumps(): array { return [ DumpDocumentAction::FILENAME_PREFIX, DumpWikiAction::FILENAME_PREFIX, ]; } /** * Scope a query to only include safe dumps. */ #[Scope] protected function onlySafeDumps(Builder $query): void { $query->where(function (Builder $query): void { foreach (Dump::safeDumps() as $path) { $query->orWhere(Dump::ATTRIBUTE_PATH, ComparisonOperator::LIKE->value, $path.'%'); } }); } }