Add Team model and controller from upstream

This commit is contained in:
Remco
2026-01-24 21:08:40 +01:00
parent e233b55c34
commit 858143a69e
3 changed files with 66 additions and 11 deletions
@@ -2,7 +2,7 @@
namespace App\Services\Community;
use App\Models\Community\Staff\WebsiteTeam;
use App\Models\Community\Teams\WebsiteTeam;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\Cache;
@@ -20,21 +20,16 @@ class TeamService
return Cache::get('hotel_teams');
}
/** @var Collection<int, WebsiteTeam> $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');
}])
/** @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', $employees, now()->addMinutes($cacheTimer));
Cache::put('hotel_teams', $teams, now()->addMinutes($cacheTimer));
}
return $employees;
return $teams;
}
}