I expirations

This commit is contained in:
Fabian Wagner 2025-11-25 10:48:09 +01:00
parent 8ef0640737
commit ab6d2f29d2
1 changed files with 18 additions and 0 deletions

View File

@ -32,4 +32,22 @@ trait HasExpiration
$this->save(); $this->save();
} }
public function scopeExpired($query)
{
return $query
->withoutGlobalScope('willExpire')
->whereNotNull('expires_at')
->where('expires_at', '<=', now());
}
public function scopeWillExpire($query)
{
return $query
->withoutGlobalScope('willExpire')
->where(function ($query) {
$query->whereNull('expires_at')
->orWhere('expires_at', '>', now());
});
}
} }