A expiration scopes

This commit is contained in:
Fabian Wagner 2025-12-04 11:34:19 +01:00
parent fe7206743c
commit b83eaefa2e
1 changed files with 19 additions and 0 deletions

View File

@ -50,4 +50,23 @@ trait HasExpiration
->orWhere('expires_at', '>', now());
});
}
public function scopeWithExpired($query)
{
return $query->withoutGlobalScope('willExpire');
}
public function scopeExpiresWithinHours($query, int $hours)
{
return $query
->withoutGlobalScope('willExpire')
->whereBetween('expires_at', [now(), now()->addHours($hours)]);
}
public function scopeExpiresFromTo($query, $from, $to)
{
return $query
->withoutGlobalScope('willExpire')
->whereBetween('expires_at', [$from, $to]);
}
}