'integer', 'published_at' => 'datetime', ]; public function group(): BelongsTo { return $this->belongsTo(TimelineGroup::class, 'group_id'); } public function items(): HasMany { return $this->hasMany(TimelineItem::class, 'year_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'); } }