'bool', 'user_id' => 'int', ]; /** Заметка не пропадает совсем: помечается deleted_at и уходит из списков */ protected bool $softDelete = true; public function author(): BelongsTo { return $this->belongsTo(User::class, 'user_id'); } /** * Адресная часть считается сама — по названию. */ public function save(): bool { if (trim((string) $this->raw('slug')) === '') { $this->setAttribute('slug', Str::slug((string) $this->raw('title'))); } return parent::save(); } public function hasFile(): bool { return trim((string) $this->raw('file_path')) !== ''; } /** * Короткий пересказ для списка. */ public function excerpt(int $length = 160): string { return Str::limit(trim(strip_tags((string) $this->raw('body'))), $length); } }