complete story 4.3 adfter validation and fixing

This commit is contained in:
Naser Mansour
2025-12-27 00:46:07 +02:00
parent 435b1c6c2e
commit efc67884dc
9 changed files with 826 additions and 90 deletions
+48
View File
@@ -41,4 +41,52 @@ class Timeline extends Model
{
return $this->hasMany(TimelineUpdate::class)->orderBy('created_at', 'asc');
}
/**
* Archive the timeline.
*/
public function archive(): void
{
$this->update(['status' => TimelineStatus::Archived]);
}
/**
* Unarchive the timeline.
*/
public function unarchive(): void
{
$this->update(['status' => TimelineStatus::Active]);
}
/**
* Check if the timeline is archived.
*/
public function isArchived(): bool
{
return $this->status === TimelineStatus::Archived;
}
/**
* Check if the timeline is active.
*/
public function isActive(): bool
{
return $this->status === TimelineStatus::Active;
}
/**
* Scope a query to only include active timelines.
*/
public function scopeActive($query)
{
return $query->where('status', TimelineStatus::Active);
}
/**
* Scope a query to only include archived timelines.
*/
public function scopeArchived($query)
{
return $query->where('status', TimelineStatus::Archived);
}
}