complete story 4.3 adfter validation and fixing
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user