feat: add legacy setting support to ease migration

This commit is contained in:
idevakk
2025-11-16 10:59:42 -08:00
parent e3da8cf950
commit cb05040c96
4 changed files with 205 additions and 4 deletions

View File

@@ -68,4 +68,31 @@ class Domain extends Model
return $query->pluck('name')->toArray();
}
/**
* Retrieve all active domains grouped by type.
*
* @return array Array with 'domains' and 'premium_domains' keys
*/
public static function getActiveDomains(): array
{
$domains = static::query()
->where('is_active', true)
->where(function ($query) {
$query->whereNull('starts_at')
->orWhere('starts_at', '<=', now());
})
->where(function ($query) {
$query->whereNull('ends_at')
->orWhere('ends_at', '>=', now());
})
->select('name', 'domain_type')
->get()
->groupBy('domain_type');
return [
'domains' => $domains->get(DomainType::PUBLIC->value, collect())->pluck('name')->toArray(),
'premium_domains' => $domains->get(DomainType::PREMIUM->value, collect())->pluck('name')->toArray(),
];
}
}