'boolean', 'published_at' => 'datetime', ]; // ── Relations ──────────────────────────────────────────────────────── public function author() { return $this->belongsTo(User::class, 'author_id'); } // ── Scopes ─────────────────────────────────────────────────────────── public function scopePublished($query) { return $query->where('is_published', true) ->where(fn ($q) => $q->whereNull('published_at')->orWhere('published_at', '<=', now())); } // ── Accessors ──────────────────────────────────────────────────────── public function getUrlAttribute(): string { return url('/blog/' . $this->slug); } }