'datetime', ]; public function years(): HasMany { return $this->hasMany(TimelineYear::class, 'group_id')->orderBy('sort'); } public function scopePublished($query) { return $query->where('status', 'publish') ->where(function ($q) { $q->whereNull('published_at') ->orWhere('published_at', '<=', now()); }); } public function scopeOrdered($query) { return $query->orderBy('sort'); } }