*/ public function fetchTeams(): Collection { $cacheEnabled = setting('enable_caching') === '1'; if (Cache::has('hotel_teams') && $cacheEnabled) { /** @var Collection */ return Cache::get('hotel_teams'); } /** @var Collection $employees */ $employees = WebsiteTeam::select(['id', 'rank_name', 'badge', 'staff_color', 'staff_background', 'job_description']) ->where('hidden_rank', false) ->orderByDesc('id') ->with(['users' => function ($query): void { /** @var \Illuminate\Database\Eloquent\Builder $query */ $query->select('id', 'username', 'look', 'motto', 'rank', 'team_id', 'online'); }]) ->get(); if ($cacheEnabled) { $cacheTimer = (int) setting('cache_timer'); Cache::put('hotel_teams', $employees, now()->addMinutes($cacheTimer)); } return $employees; } }