diff --git a/Updated_Cms/app/Http/Controllers/Community/Teams/WebsiteTeam.php b/Updated_Cms/app/Http/Controllers/Community/Teams/WebsiteTeam.php new file mode 100644 index 0000000000..e5a5dba2db --- /dev/null +++ b/Updated_Cms/app/Http/Controllers/Community/Teams/WebsiteTeam.php @@ -0,0 +1,28 @@ +withCount('applications') + ->get(); + + return view('community.teams', compact('teams')); + } + + public function show($id) + { + $team = WebsiteTeam::where('is_active', true) + ->with('applications') + ->findOrFail($id); + + return view('community.team-applications', compact('team')); + } +} \ No newline at end of file diff --git a/Updated_Cms/app/Models/Community/Teams/WebsiteTeam.php b/Updated_Cms/app/Models/Community/Teams/WebsiteTeam.php new file mode 100644 index 0000000000..288f8506dc --- /dev/null +++ b/Updated_Cms/app/Models/Community/Teams/WebsiteTeam.php @@ -0,0 +1,32 @@ + 'boolean', + ]; + + public function applications(): HasMany + { + return $this->hasMany(\App\Models\Community\Staff\WebsiteStaffApplications::class, 'team_id'); + } + + public function openPositions(): HasMany + { + return $this->hasMany(\App\Models\Community\Staff\WebsiteOpenPosition::class, 'team_id'); + } +} \ No newline at end of file diff --git a/Updated_Cms/app/Services/Community/TeamService.php b/Updated_Cms/app/Services/Community/TeamService.php index d37fecc9e1..caf7625082 100644 --- a/Updated_Cms/app/Services/Community/TeamService.php +++ b/Updated_Cms/app/Services/Community/TeamService.php @@ -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 $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 $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; } }