Files
Epicnabbo-Catalogus-Updated…/Updated_Cms/app/Services/Community/TeamService.php
T
2026-01-24 21:08:40 +01:00

36 lines
898 B
PHP

<?php
namespace App\Services\Community;
use App\Models\Community\Teams\WebsiteTeam;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\Cache;
class TeamService
{
/**
* @return Collection<int, WebsiteTeam>
*/
public function fetchTeams(): Collection
{
$cacheEnabled = setting('enable_caching') === '1';
if (Cache::has('hotel_teams') && $cacheEnabled) {
/** @var Collection<int, WebsiteTeam> */
return Cache::get('hotel_teams');
}
/** @var Collection<int, WebsiteTeam> $teams */
$teams = WebsiteTeam::where('is_active', true)
->orderBy('name')
->get();
if ($cacheEnabled) {
$cacheTimer = (int) setting('cache_timer');
Cache::put('hotel_teams', $teams, now()->addMinutes($cacheTimer));
}
return $teams;
}
}