'datetime', ]; public function getRouteKeyName(): string { return 'slug'; } public function author(): BelongsTo { return $this->belongsTo(User::class, 'author_id'); } public function scopePublished(Builder $query): Builder { return $query->whereNotNull('published_at')->where('published_at', '<=', now()); } public function getIsPublishedAttribute(): bool { return $this->published_at !== null && $this->published_at->lte(now()); } public function getCoverUrlAttribute(): ?string { $cover = (string) ($this->attributes['cover_image'] ?? ''); if ($cover === '') { return null; } if (preg_match('/^https?:\/\//i', $cover)) { return $cover; } return Storage::url($cover); } }