You've already forked Epicnabbo-Catalogus-Updated-Daily
🆙 More fixes 🆙
This commit is contained in:
@@ -8,12 +8,18 @@ use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class RareValueCategoriesService
|
||||
{
|
||||
/**
|
||||
* @return Collection<int, WebsiteRareValueCategory>
|
||||
*/
|
||||
public function fetchAllCategories(): Collection
|
||||
{
|
||||
return WebsiteRareValueCategory::all();
|
||||
}
|
||||
|
||||
public function fetchCategoriesByPriority(): Builder|Collection
|
||||
/**
|
||||
* @return Collection<int, WebsiteRareValueCategory>
|
||||
*/
|
||||
public function fetchCategoriesByPriority(): Collection
|
||||
{
|
||||
return WebsiteRareValueCategory::orderBy('priority')->with('furniture')->get();
|
||||
}
|
||||
@@ -23,12 +29,16 @@ class RareValueCategoriesService
|
||||
return WebsiteRareValueCategory::orderBy('priority')->whereId($id)->with('furniture')->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, WebsiteRareValueCategory>
|
||||
*/
|
||||
public function searchCategories(string $searchTerm): Collection
|
||||
{
|
||||
return WebsiteRareValueCategory::orderBy('priority')->whereHas('furniture', function ($query) use ($searchTerm): void {
|
||||
$query->where('name', 'like', '%' . $searchTerm . '%');
|
||||
})
|
||||
->with(['furniture' => function ($query) use ($searchTerm): void {
|
||||
/** @var Builder $query */
|
||||
$query->where('name', 'like', '%' . $searchTerm . '%');
|
||||
}])
|
||||
->get();
|
||||
|
||||
@@ -16,17 +16,20 @@ class StaffApplicationService
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Collection<int, WebsiteOpenPosition>
|
||||
*/
|
||||
public function fetchOpenPositions(): Collection
|
||||
{
|
||||
return WebsiteOpenPosition::canApply()->with('permission')->get();
|
||||
}
|
||||
|
||||
public function hasUserAppliedForPosition($user, $positionId): bool
|
||||
public function hasUserAppliedForPosition(User $user, int $positionId): bool
|
||||
{
|
||||
return $user->applications()->where('rank_id', $positionId)->exists();
|
||||
}
|
||||
|
||||
public function isPositionOpenForApplication($position): bool
|
||||
public function isPositionOpenForApplication(WebsiteOpenPosition $position): bool
|
||||
{
|
||||
$currentTime = now();
|
||||
|
||||
|
||||
@@ -10,22 +10,32 @@ use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class StaffService
|
||||
{
|
||||
/**
|
||||
* @return Collection<int, Permission>
|
||||
*/
|
||||
public function fetchStaffPositions(): Collection
|
||||
{
|
||||
$cacheEnabled = setting('enable_caching') === '1';
|
||||
|
||||
if ($cacheEnabled && Cache::has('staff_positions')) {
|
||||
/** @var Collection<int, Permission> */
|
||||
return Cache::get('staff_positions');
|
||||
}
|
||||
|
||||
/** @var \App\Models\User|null $user */
|
||||
$user = Auth::user();
|
||||
$userRank = $user ? $user->rank : 0;
|
||||
|
||||
/** @var Collection<int, Permission> $employees */
|
||||
$employees = Permission::query()
|
||||
->select('id', 'rank_name', 'badge', 'staff_color', 'job_description')
|
||||
->when(Auth::user()->rank < (int) setting('min_rank_to_see_hidden_staff'), fn ($query) => $query->where('hidden_rank', false))
|
||||
->when($userRank < (int) setting('min_rank_to_see_hidden_staff'), fn ($query) => $query->where('hidden_rank', false))
|
||||
->where('id', '>=', setting('min_staff_rank'))
|
||||
->orderByDesc('id')
|
||||
->with(['users' => function ($query): void {
|
||||
->with(['users' => function ($query) use ($userRank): void {
|
||||
/** @var \Illuminate\Database\Eloquent\Builder $query */
|
||||
$query->select('id', 'username', 'rank', 'motto', 'look', 'hidden_staff', 'online')
|
||||
->when(Auth::user()->rank < (int) setting('min_rank_to_see_hidden_staff'), fn ($query) => $query->where('hidden_staff', false));
|
||||
->when($userRank < (int) setting('min_rank_to_see_hidden_staff'), fn ($query) => $query->where('hidden_staff', false));
|
||||
}])
|
||||
->get();
|
||||
|
||||
@@ -37,14 +47,19 @@ class StaffService
|
||||
return $employees;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<int, int>
|
||||
*/
|
||||
public function fetchEmployeeIds(): array
|
||||
{
|
||||
$cacheEnabled = setting('enable_caching') === '1';
|
||||
|
||||
if ($cacheEnabled && Cache::has('staff_ids')) {
|
||||
/** @var array<int, int> */
|
||||
return Cache::get('staff_ids');
|
||||
}
|
||||
|
||||
/** @var array<int, int> $staffIds */
|
||||
$staffIds = User::select('id')
|
||||
->where('rank', '>=', setting('min_staff_rank'))
|
||||
->get()
|
||||
|
||||
@@ -8,18 +8,24 @@ use Illuminate\Support\Facades\Cache;
|
||||
|
||||
class TeamService
|
||||
{
|
||||
/**
|
||||
* @return Collection<int, WebsiteTeam>
|
||||
*/
|
||||
public function fetchTeams(): Collection
|
||||
{
|
||||
$cacheEnabled = setting('enable_caching') === '1';
|
||||
|
||||
if (Cache::has('hotel_teams') && $cacheEnabled) {
|
||||
/** @var Collection<int, WebsiteTeam> */
|
||||
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');
|
||||
}])
|
||||
->get();
|
||||
|
||||
Reference in New Issue
Block a user