Files
2026-05-09 17:32:17 +02:00

42 lines
1.1 KiB
PHP
Executable File

<?php
namespace App\Services\Community;
use App\Models\Community\Teams\WebsiteTeam;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
readonly class TeamService
{
public function fetchTeams(): Collection
{
$cacheEnabled = setting('enable_caching') === '1';
if ($cacheEnabled && Cache::has('hotel_teams')) {
return Cache::get('hotel_teams');
}
$employees = WebsiteTeam::query()->select([
'id',
'rank_name',
'badge',
'staff_color',
'staff_background',
'job_description',
])
->where('hidden_rank', false)
->orderByDesc('id')
->with(['users' => function ($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;
}
}