You've already forked Epicnabbo-Catalogus-Updated-Daily
Add Team model and controller from upstream
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Community\Teams;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Community\Teams\WebsiteTeam;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
|
||||||
|
class WebsiteTeamController extends Controller
|
||||||
|
{
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
$teams = WebsiteTeam::where('is_active', true)
|
||||||
|
->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'));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models\Community\Teams;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\HasMany;
|
||||||
|
|
||||||
|
class WebsiteTeam extends Model
|
||||||
|
{
|
||||||
|
protected $table = 'website_teams';
|
||||||
|
|
||||||
|
protected $fillable = [
|
||||||
|
'name',
|
||||||
|
'description',
|
||||||
|
'rank_name',
|
||||||
|
'is_active',
|
||||||
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'is_active' => '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');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Services\Community;
|
namespace App\Services\Community;
|
||||||
|
|
||||||
use App\Models\Community\Staff\WebsiteTeam;
|
use App\Models\Community\Teams\WebsiteTeam;
|
||||||
use Illuminate\Database\Eloquent\Collection;
|
use Illuminate\Database\Eloquent\Collection;
|
||||||
use Illuminate\Support\Facades\Cache;
|
use Illuminate\Support\Facades\Cache;
|
||||||
|
|
||||||
@@ -20,21 +20,16 @@ class TeamService
|
|||||||
return Cache::get('hotel_teams');
|
return Cache::get('hotel_teams');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var Collection<int, WebsiteTeam> $employees */
|
/** @var Collection<int, WebsiteTeam> $teams */
|
||||||
$employees = WebsiteTeam::select(['id', 'rank_name', 'badge', 'staff_color', 'staff_background', 'job_description'])
|
$teams = WebsiteTeam::where('is_active', true)
|
||||||
->where('hidden_rank', false)
|
->orderBy('name')
|
||||||
->orderByDesc('id')
|
|
||||||
->with(['users' => function ($query): void {
|
|
||||||
/** @var \Illuminate\Database\Eloquent\Builder $query */
|
|
||||||
$query->select('id', 'username', 'look', 'motto', 'rank', 'team_id', 'online');
|
|
||||||
}])
|
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
if ($cacheEnabled) {
|
if ($cacheEnabled) {
|
||||||
$cacheTimer = (int) setting('cache_timer');
|
$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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user