🆙 Added fixed cms

This commit is contained in:
Remco
2026-01-07 19:32:43 +01:00
parent fdb0dc276d
commit 711fa2c29e
3992 changed files with 183381 additions and 0 deletions
@@ -0,0 +1,17 @@
<?php
namespace App\Services\Community;
use App\Models\Miscellaneous\CameraWeb;
class CameraService
{
public function fetchPhotos(bool $paginate = false, int $perPage = 8): mixed
{
$photos = CameraWeb::where('visible', true)
->latest('id')
->with('user:id,username,look');
return $paginate ? $photos->paginate($perPage) : $photos->get();
}
}
@@ -0,0 +1,36 @@
<?php
namespace App\Services\Community\RareValues;
use App\Models\Community\RareValue\WebsiteRareValueCategory;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
class RareValueCategoriesService
{
public function fetchAllCategories(): Collection
{
return WebsiteRareValueCategory::all();
}
public function fetchCategoriesByPriority(): Builder|Collection
{
return WebsiteRareValueCategory::orderBy('priority')->with('furniture')->get();
}
public function fetchCategoryById(int $id): ?WebsiteRareValueCategory
{
return WebsiteRareValueCategory::orderBy('priority')->whereId($id)->with('furniture')->first();
}
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 {
$query->where('name', 'like', '%' . $searchTerm . '%');
}])
->get();
}
}
@@ -0,0 +1,5 @@
<?php
namespace App\Services\Community\RareValues;
class RareValuesService {}
@@ -0,0 +1,35 @@
<?php
namespace App\Services\Community;
use App\Models\Community\Staff\WebsiteOpenPosition;
use App\Models\User;
use Illuminate\Database\Eloquent\Collection;
class StaffApplicationService
{
public function storeApplication(User $user, int $positionId, string $content): void
{
$user->applications()->create([
'rank_id' => $positionId,
'content' => $content,
]);
}
public function fetchOpenPositions(): Collection
{
return WebsiteOpenPosition::canApply()->with('permission')->get();
}
public function hasUserAppliedForPosition($user, $positionId): bool
{
return $user->applications()->where('rank_id', $positionId)->exists();
}
public function isPositionOpenForApplication($position): bool
{
$currentTime = now();
return $position->apply_from <= $currentTime && $position->apply_to >= $currentTime;
}
}
@@ -0,0 +1,60 @@
<?php
namespace App\Services\Community;
use App\Models\Game\Permission;
use App\Models\User;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Cache;
class StaffService
{
public function fetchStaffPositions(): Collection
{
$cacheEnabled = setting('enable_caching') === '1';
if ($cacheEnabled && Cache::has('staff_positions')) {
return Cache::get('staff_positions');
}
$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))
->where('id', '>=', setting('min_staff_rank'))
->orderByDesc('id')
->with(['users' => function ($query): void {
$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));
}])
->get();
if ($cacheEnabled) {
$cacheTimer = (int) setting('cache_timer');
Cache::put('staff_positions', $employees, now()->addMinutes($cacheTimer));
}
return $employees;
}
public function fetchEmployeeIds(): array
{
$cacheEnabled = setting('enable_caching') === '1';
if ($cacheEnabled && Cache::has('staff_ids')) {
return Cache::get('staff_ids');
}
$staffIds = User::select('id')
->where('rank', '>=', setting('min_staff_rank'))
->get()
->pluck('id')->toArray();
if ($cacheEnabled) {
$cacheTimer = (int) setting('cache_timer');
Cache::put('staff_ids', $staffIds, now()->addMinutes($cacheTimer));
}
return $staffIds;
}
}
@@ -0,0 +1,34 @@
<?php
namespace App\Services\Community;
use App\Models\Community\Staff\WebsiteTeam;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Support\Facades\Cache;
class TeamService
{
public function fetchTeams(): Collection
{
$cacheEnabled = setting('enable_caching') === '1';
if (Cache::has('hotel_teams') && $cacheEnabled) {
return Cache::get('hotel_teams');
}
$employees = WebsiteTeam::select(['id', 'rank_name', 'badge', 'staff_color', 'staff_background', 'job_description'])
->where('hidden_rank', false)
->orderByDesc('id')
->with(['users' => function ($query): void {
$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;
}
}