Rector Changes

This commit is contained in:
Refringe 2025-01-30 00:23:55 -05:00
parent f9c17b2a6c
commit cb5c3caad8
Signed by: Refringe
SSH Key Fingerprint: SHA256:t865XsQpfTeqPRBMN2G6+N8wlDjkgUCZF3WGW6O9N/k
153 changed files with 961 additions and 648 deletions

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Actions\Fortify;
use App\Models\User;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Actions\Fortify;
use Illuminate\Validation\Rules\Password;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Actions\Fortify;
use App\Models\User;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Actions\Fortify;
use App\Models\User;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Actions\Fortify;
use App\Models\User;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Actions\Jetstream;
use App\Models\User;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Console\Commands;
use App\Jobs\Import\ImportHubDataJob;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Console\Commands;
use App\Jobs\ResolveDependenciesJob;

View File

@ -1,7 +1,11 @@
<?php
declare(strict_types=1);
namespace App\Console\Commands;
use App\Models\Mod;
use App\Models\User;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Artisan;
@ -15,8 +19,8 @@ class SearchSyncCommand extends Command
{
Artisan::call('scout:delete-all-indexes');
Artisan::call('scout:sync-index-settings');
Artisan::call('scout:import', ['model' => '\App\Models\Mod']);
Artisan::call('scout:import', ['model' => '\App\Models\User']);
Artisan::call('scout:import', ['model' => Mod::class]);
Artisan::call('scout:import', ['model' => User::class]);
$this->info('The search synchronisation jobs have been added to the queue');
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Console\Commands;
use App\Jobs\SptVersionModCountsJob;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Console\Commands;
use App\Jobs\UpdateModDownloadsJob;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Console\Commands;
use Illuminate\Console\Command;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Exceptions;
use Exception;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Exceptions;
use Exception;

View File

@ -1,14 +1,23 @@
<?php
declare(strict_types=1);
namespace App\Filament\Resources;
use App\Filament\Resources\UserResource\Pages;
use App\Filament\Resources\UserResource\Pages\CreateUser;
use App\Filament\Resources\UserResource\Pages\EditUser;
use App\Filament\Resources\UserResource\Pages\ListUsers;
use App\Models\User;
use Filament\Forms;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Resources\Resource;
use Filament\Tables;
use Filament\Tables\Actions\BulkActionGroup;
use Filament\Tables\Actions\DeleteBulkAction;
use Filament\Tables\Actions\EditAction;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Table;
use Override;
class UserResource extends Resource
{
@ -16,46 +25,48 @@ class UserResource extends Resource
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
#[Override]
public static function form(Form $form): Form
{
return $form
->schema([
Forms\Components\TextInput::make('name')
TextInput::make('name')
->required()
->maxLength(255),
Forms\Components\TextInput::make('email')
TextInput::make('email')
->email()
->required()
->maxLength(255),
Forms\Components\DateTimePicker::make('email_verified_at'),
Forms\Components\TextInput::make('password')
DateTimePicker::make('email_verified_at'),
TextInput::make('password')
->password()
->required()
->maxLength(255),
Forms\Components\TextInput::make('user_role_id')
TextInput::make('user_role_id')
->numeric(),
Forms\Components\TextInput::make('profile_photo_path')
TextInput::make('profile_photo_path')
->maxLength(2048),
Forms\Components\DateTimePicker::make('created_at'),
Forms\Components\DateTimePicker::make('updated_at'),
DateTimePicker::make('created_at'),
DateTimePicker::make('updated_at'),
]);
}
#[Override]
public static function table(Table $table): Table
{
return $table
->columns([
Tables\Columns\TextColumn::make('name')
TextColumn::make('name')
->searchable(),
Tables\Columns\TextColumn::make('email')
TextColumn::make('email')
->searchable(),
Tables\Columns\TextColumn::make('role.name')
TextColumn::make('role.name')
->sortable(),
Tables\Columns\TextColumn::make('email_verified_at')
TextColumn::make('email_verified_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
Tables\Columns\TextColumn::make('created_at')
TextColumn::make('created_at')
->dateTime()
->sortable()
->toggleable(isToggledHiddenByDefault: true),
@ -64,15 +75,16 @@ class UserResource extends Resource
//
])
->actions([
Tables\Actions\EditAction::make(),
EditAction::make(),
])
->bulkActions([
Tables\Actions\BulkActionGroup::make([
Tables\Actions\DeleteBulkAction::make(),
BulkActionGroup::make([
DeleteBulkAction::make(),
]),
]);
}
#[Override]
public static function getRelations(): array
{
return [
@ -80,12 +92,13 @@ class UserResource extends Resource
];
}
#[Override]
public static function getPages(): array
{
return [
'index' => Pages\ListUsers::route('/'),
'create' => Pages\CreateUser::route('/create'),
'edit' => Pages\EditUser::route('/{record}/edit'),
'index' => ListUsers::route('/'),
'create' => CreateUser::route('/create'),
'edit' => EditUser::route('/{record}/edit'),
];
}
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Filament\Resources\UserResource\Pages;
use App\Filament\Resources\UserResource;

View File

@ -1,9 +1,11 @@
<?php
declare(strict_types=1);
namespace App\Filament\Resources\UserResource\Pages;
use App\Filament\Resources\UserResource;
use Filament\Actions;
use Filament\Actions\DeleteAction;
use Filament\Resources\Pages\EditRecord;
class EditUser extends EditRecord
@ -13,7 +15,7 @@ class EditUser extends EditRecord
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
DeleteAction::make(),
];
}
}

View File

@ -1,9 +1,11 @@
<?php
declare(strict_types=1);
namespace App\Filament\Resources\UserResource\Pages;
use App\Filament\Resources\UserResource;
use Filament\Actions;
use Filament\Actions\CreateAction;
use Filament\Resources\Pages\ListRecords;
class ListUsers extends ListRecords
@ -13,7 +15,7 @@ class ListUsers extends ListRecords
protected function getHeaderActions(): array
{
return [
Actions\CreateAction::make(),
CreateAction::make(),
];
}
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Api;
use App\Http\Controllers\Controller;
@ -34,16 +36,16 @@ class AuthController extends Controller
#[Response(['message' => 'authenticated', 'data' => ['token' => 'YOUR_API_KEY'], 'status' => 200], status: 200, description: 'Authenticated successfully')]
#[Response(['message' => 'invalid credentials', 'status' => 401], status: 401, description: 'Invalid credentials')]
#[ResponseField('token', description: 'The newly created read-only API token to use for future authenticated requests.')]
public function login(LoginUserRequest $request): JsonResponse
public function login(LoginUserRequest $loginUserRequest): JsonResponse
{
$request->validated($request->all());
$loginUserRequest->validated($loginUserRequest->all());
if (! Auth::attempt($request->only('email', 'password'))) {
if (! Auth::attempt($loginUserRequest->only('email', 'password'))) {
return $this->error(__('invalid credentials'), 401);
}
$user = User::firstWhere('email', $request->email);
$tokenName = $request->token_name ?? __('Dynamic API Token');
$user = User::firstWhere('email', $loginUserRequest->email);
$tokenName = $loginUserRequest->token_name ?? __('Dynamic API Token');
return $this->success(__('authenticated'), [
// Only allowing the 'read' scope to be dynamically created. Can revisit later when writes are possible.

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Api\V0;
use App\Http\Controllers\Controller;
@ -17,7 +19,7 @@ class ApiController extends Controller
{
try {
$param = request()->get('include');
} catch (NotFoundExceptionInterface|ContainerExceptionInterface $e) {
} catch (NotFoundExceptionInterface|ContainerExceptionInterface) {
return false;
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Api\V0;
use App\Http\Filters\V1\ModFilter;
@ -33,9 +35,9 @@ class ModController extends ApiController
#[QueryParam('filter[updated_at]', 'string', 'Filter by the `updated_at` attribute. Ranges are possible by separating the dates with a comma.', required: false, example: '2023-12-31,2024-12-31')]
#[QueryParam('filter[published_at]', 'string', 'Filter by the `published_at` attribute. Ranges are possible by seperating the dates with a comma.', required: false, example: '2023-12-31,2024-12-31')]
#[QueryParam('sort', 'string', 'Sort the results by a comma seperated list of attributes. The default sort direction is ASC, append the attribute name with a minus to sort DESC.', required: false, example: '-featured,name')]
public function index(ModFilter $filters): AnonymousResourceCollection
public function index(ModFilter $modFilter): AnonymousResourceCollection
{
return ModResource::collection(Mod::filter($filters)->paginate());
return ModResource::collection(Mod::filter($modFilter)->paginate());
}
/**

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers\Api\V0;
use App\Http\Filters\V1\UserFilter;
@ -24,9 +26,9 @@ class UsersController extends ApiController
#[QueryParam('filter[created_at]', 'string', 'Filter by the `created_at` attribute. Ranges are possible by separating the dates with a comma.', required: false, example: '2023-12-31,2024-12-31')]
#[QueryParam('filter[updated_at]', 'string', 'Filter by the `updated_at` attribute. Ranges are possible by separating the dates with a comma.', required: false, example: '2023-12-31,2024-12-31')]
#[QueryParam('sort', 'string', 'Sort the results by a comma seperated list of attributes. The default sort direction is ASC, append the attribute name with a minus to sort DESC.', required: false, example: 'created_at,-name')]
public function index(UserFilter $filters): AnonymousResourceCollection
public function index(UserFilter $userFilter): AnonymousResourceCollection
{
return UserResource::collection(User::filter($filters)->paginate());
return UserResource::collection(User::filter($userFilter)->paginate());
}
/**

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers;
abstract class Controller

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers;
use App\Http\Requests\ModRequest;
@ -19,11 +21,11 @@ class ModController extends Controller
return view('mod.index');
}
public function store(ModRequest $request): ModResource
public function store(ModRequest $modRequest): ModResource
{
$this->authorize('create', Mod::class);
return new ModResource(Mod::create($request->validated()));
return new ModResource(Mod::create($modRequest->validated()));
}
public function show(int $modId, string $slug): View
@ -43,14 +45,14 @@ class ModController extends Controller
$this->authorize('view', $mod);
return view('mod.show', compact(['mod']));
return view('mod.show', ['mod' => $mod]);
}
public function update(ModRequest $request, Mod $mod): ModResource
public function update(ModRequest $modRequest, Mod $mod): ModResource
{
$this->authorize('update', $mod);
$mod->update($request->validated());
$mod->update($modRequest->validated());
return new ModResource($mod);
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers;
use App\Models\ModVersion;

View File

@ -1,9 +1,12 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers;
use App\Models\OAuthConnection;
use App\Models\User;
use Exception;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
@ -50,7 +53,7 @@ class SocialiteController extends Controller
try {
$providerUser = Socialite::driver($provider)->user();
} catch (\Exception $e) {
} catch (Exception) {
return redirect()->route('login')->withErrors('Unable to login using '.$provider.'. Please try again.');
}
@ -86,6 +89,7 @@ class SocialiteController extends Controller
while (User::whereName($username.$random)->exists()) {
$random = '-'.Str::random(5);
}
$username .= $random;
// The user has not connected their account with this OAuth provider before, so a new connection needs to be

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Http\Controllers;
use App\Models\User;
@ -35,6 +37,6 @@ class UserController extends Controller
abort(403);
}
return view('user.show', compact('user', 'mods'));
return view('user.show', ['user' => $user, 'mods' => $mods]);
}
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Http\Filters;
use App\Models\Mod;
@ -13,17 +15,14 @@ class ModFilter
*/
protected Builder $builder;
/**
* The filters to apply.
*/
protected array $filters;
/**
* Create a new ModFilter instance.
*/
public function __construct(array $filters)
public function __construct(/**
* The filters to apply.
*/
protected array $filters)
{
$this->filters = $filters;
$this->builder = $this->baseQuery();
}
@ -34,7 +33,7 @@ class ModFilter
{
return Mod::query()
->select('mods.*')
->whereExists(function ($query) {
->whereExists(function ($query): void {
$query->select(DB::raw(1))
->from('mod_versions')
->join('mod_version_spt_version', 'mod_versions.id', '=', 'mod_version_spt_version.mod_version_id')
@ -54,7 +53,7 @@ class ModFilter
*/
private function query(string $term): Builder
{
return $this->builder->whereLike('mods.name', "%{$term}%");
return $this->builder->whereLike('mods.name', sprintf('%%%s%%', $term));
}
/**
@ -100,7 +99,7 @@ class ModFilter
*/
private function sptVersions(array $versions): Builder
{
return $this->builder->whereExists(function ($query) use ($versions) {
return $this->builder->whereExists(function ($query) use ($versions): void {
$query->select(DB::raw(1))
->from('mod_versions')
->join('mod_version_spt_version', 'mod_versions.id', '=', 'mod_version_spt_version.mod_version_id')

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Http\Filters\V1;
use Illuminate\Database\Eloquent\Builder;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Http\Filters\V1;
use App\Traits\V1\FilterMethods;
@ -18,11 +20,6 @@ abstract class QueryFilter
*/
protected Builder $builder;
/**
* The request instance.
*/
protected Request $request;
/**
* The sortable fields.
*/
@ -31,10 +28,12 @@ abstract class QueryFilter
/**
* Create a new QueryFilter instance.
*/
public function __construct(Request $request)
{
$this->request = $request;
}
public function __construct(
/**
* The request instance.
*/
protected Request $request
) {}
/**
* Iterate over each of the filter options and call the appropriate method if it exists.

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Http\Filters\V1;
use Illuminate\Database\Eloquent\Builder;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Http\Requests\Api;
use Illuminate\Foundation\Http\FormRequest;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Http\Requests\Api\V0;
use Illuminate\Foundation\Http\FormRequest;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Http\Requests\Api\V0;
use Illuminate\Foundation\Http\FormRequest;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Http\Requests\Api\V0;
use Illuminate\Foundation\Http\FormRequest;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Http\Requests\Api\V0;
use Illuminate\Foundation\Http\FormRequest;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;

View File

@ -1,10 +1,13 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources\Api\V0;
use App\Models\License;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Override;
/** @mixin License */
class LicenseResource extends JsonResource
@ -12,6 +15,7 @@ class LicenseResource extends JsonResource
/**
* Transform the resource into an array.
*/
#[Override]
public function toArray(Request $request): array
{
return [

View File

@ -1,11 +1,14 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources\Api\V0;
use App\Http\Controllers\Api\V0\ApiController;
use App\Models\Mod;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Override;
/** @mixin Mod */
class ModResource extends JsonResource
@ -13,6 +16,7 @@ class ModResource extends JsonResource
/**
* Transform the resource into an array.
*/
#[Override]
public function toArray(Request $request): array
{
$this->load(['users', 'versions', 'license']);
@ -39,7 +43,7 @@ class ModResource extends JsonResource
'published_at' => $this->published_at,
],
'relationships' => [
'users' => $this->users->map(fn ($user) => [
'users' => $this->users->map(fn ($user): array => [
'data' => [
'type' => 'user',
'id' => $user->id,
@ -48,7 +52,7 @@ class ModResource extends JsonResource
'self' => $user->profileUrl(),
],
])->toArray(),
'versions' => $this->versions->map(fn ($version) => [
'versions' => $this->versions->map(fn ($version): array => [
'data' => [
'type' => 'version',
'id' => $version->id,
@ -70,11 +74,11 @@ class ModResource extends JsonResource
'includes' => $this->when(
ApiController::shouldInclude(['users', 'license', 'versions']),
fn () => collect([
'users' => $this->users->map(fn ($user) => new UserResource($user)),
'users' => $this->users->map(fn ($user): UserResource => new UserResource($user)),
'license' => new LicenseResource($this->license),
'versions' => $this->versions->map(fn ($version) => new ModVersionResource($version)),
'versions' => $this->versions->map(fn ($version): ModVersionResource => new ModVersionResource($version)),
])
->filter(fn ($value, $key) => ApiController::shouldInclude($key))
->filter(fn ($value, $key): bool => ApiController::shouldInclude($key))
->flatten(1)
->values()
),

View File

@ -1,10 +1,13 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources\Api\V0;
use App\Models\ModVersion;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Override;
/** @mixin ModVersion */
class ModVersionResource extends JsonResource
@ -12,6 +15,7 @@ class ModVersionResource extends JsonResource
/**
* Transform the resource into an array.
*/
#[Override]
public function toArray(Request $request): array
{
return [
@ -23,10 +27,10 @@ class ModVersionResource extends JsonResource
'version' => $this->version,
// TODO: This should only be visible on the mod version show route(?) which doesn't exist.
//'description' => $this->when(
// 'description' => $this->when(
// $request->routeIs('api.v0.modversion.show'),
// $this->description
//),
// ),
'link' => $this->downloadUrl(absolute: true),
'virus_total_link' => $this->virus_total_link,

View File

@ -1,11 +1,14 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources\Api\V0;
use App\Http\Controllers\Api\V0\ApiController;
use App\Models\User;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Override;
/** @mixin User */
class UserResource extends JsonResource
@ -13,6 +16,7 @@ class UserResource extends JsonResource
/**
* Transform the resource into an array.
*/
#[Override]
public function toArray(Request $request): array
{
$this->load('role');

View File

@ -1,10 +1,13 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources\Api\V0;
use App\Models\UserRole;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Override;
/** @mixin UserRole */
class UserRoleResource extends JsonResource
@ -12,6 +15,7 @@ class UserRoleResource extends JsonResource
/**
* Transform the resource into an array.
*/
#[Override]
public function toArray(Request $request): array
{
return [

View File

@ -1,10 +1,13 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources;
use App\Models\License;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Override;
/** @mixin License */
class LicenseResource extends JsonResource
@ -12,6 +15,7 @@ class LicenseResource extends JsonResource
/**
* Transform the resource into an array.
*/
#[Override]
public function toArray(Request $request): array
{
return [

View File

@ -1,10 +1,13 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources;
use App\Models\Mod;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Override;
/** @mixin Mod */
class ModResource extends JsonResource
@ -12,6 +15,7 @@ class ModResource extends JsonResource
/**
* Transform the resource into an array.
*/
#[Override]
public function toArray(Request $request): array
{
return [

View File

@ -1,10 +1,13 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources;
use App\Models\ModVersion;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Override;
/** @mixin ModVersion */
class ModVersionResource extends JsonResource
@ -12,6 +15,7 @@ class ModVersionResource extends JsonResource
/**
* Transform the resource into an array.
*/
#[Override]
public function toArray(Request $request): array
{
return [

View File

@ -1,10 +1,13 @@
<?php
declare(strict_types=1);
namespace App\Http\Resources;
use App\Models\SptVersion;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Override;
/** @mixin SptVersion */
class SptVersionResource extends JsonResource
@ -12,6 +15,7 @@ class SptVersionResource extends JsonResource
/**
* Transform the resource into an array.
*/
#[Override]
public function toArray(Request $request): array
{
return [

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Jobs\Import\DataTransferObjects;
class HubUser

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Jobs\Import;
use App\Exceptions\InvalidVersionNumberException;
@ -34,7 +36,10 @@ use Throwable;
class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
public function handle(): void
{
@ -86,7 +91,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
DB::connection('mysql_hub')
->table('wcf1_user_avatar')
->orderBy('avatarID')
->chunk(200, function ($avatars) {
->chunk(200, function ($avatars): void {
$insertData = [];
foreach ($avatars as $avatar) {
$insertData[] = [
@ -97,7 +102,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
];
}
if ($insertData) {
if ($insertData !== []) {
DB::table('temp_user_avatar')->insert($insertData);
}
});
@ -117,7 +122,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
DB::connection('mysql_hub')
->table('wcf1_user_option_value')
->orderBy('userID')
->chunk(200, function ($options) {
->chunk(200, function ($options): void {
$insertData = [];
foreach ($options as $option) {
$insertData[] = [
@ -126,7 +131,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
];
}
if ($insertData) {
if ($insertData !== []) {
DB::table('temp_user_options_values')->insert($insertData);
}
});
@ -146,7 +151,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
DB::connection('mysql_hub')
->table('filebase1_file_author')
->orderBy('fileID')
->chunk(200, function ($relationships) {
->chunk(200, function ($relationships): void {
$insertData = [];
foreach ($relationships as $relationship) {
$insertData[] = [
@ -155,7 +160,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
];
}
if ($insertData) {
if ($insertData !== []) {
DB::table('temp_file_author')->insert($insertData);
}
});
@ -176,7 +181,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
DB::connection('mysql_hub')
->table('filebase1_file_option_value')
->orderBy('fileID')
->chunk(200, function ($options) {
->chunk(200, function ($options): void {
$insertData = [];
foreach ($options as $option) {
$insertData[] = [
@ -186,7 +191,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
];
}
if ($insertData) {
if ($insertData !== []) {
DB::table('temp_file_option_values')->insert($insertData);
}
});
@ -208,7 +213,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
DB::connection('mysql_hub')
->table('filebase1_file_content')
->orderBy('fileID')
->chunk(200, function ($contents) {
->chunk(200, function ($contents): void {
$insertData = [];
foreach ($contents as $content) {
$insertData[] = [
@ -219,7 +224,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
];
}
if ($insertData) {
if ($insertData !== []) {
DB::table('temp_file_content')->insert($insertData);
}
});
@ -240,7 +245,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
->table('wcf1_label_object')
->where('objectTypeID', 387)
->orderBy('labelID')
->chunk(200, function ($options) {
->chunk(200, function ($options): void {
$insertData = [];
foreach ($options as $option) {
$insertData[] = [
@ -249,7 +254,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
];
}
if ($insertData) {
if ($insertData !== []) {
DB::table('temp_file_version_labels')->insert($insertData);
}
});
@ -269,7 +274,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
DB::connection('mysql_hub')
->table('filebase1_file_version_content')
->orderBy('versionID')
->chunk(200, function ($options) {
->chunk(200, function ($options): void {
$insertData = [];
foreach ($options as $option) {
$insertData[] = [
@ -278,7 +283,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
];
}
if ($insertData) {
if ($insertData !== []) {
DB::table('temp_file_version_content')->insert($insertData);
}
});
@ -297,7 +302,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
->table('wcf1_label')
->where('groupID', 1)
->orderBy('labelID')
->chunk(100, function (Collection $versions) {
->chunk(100, function (Collection $versions): void {
$insertData = [];
foreach ($versions as $version) {
$insertData[] = [
@ -307,7 +312,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
];
}
if ($insertData) {
if ($insertData !== []) {
DB::table('temp_spt_version_tags')->insert($insertData);
}
});
@ -340,9 +345,10 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
'r.rankTitle',
)
->leftJoin('wcf1_user_rank as r', 'u.rankID', '=', 'r.rankID')
->chunkById(250, function (Collection $users) use ($curl) {
$userData = $bannedUsers = $userRanks = [];
->chunkById(250, function (Collection $users) use ($curl): void {
$userData = [];
$bannedUsers = [];
$userRanks = [];
foreach ($users as $user) {
$hubUser = new HubUser(
$user->userID,
@ -384,16 +390,16 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
/**
* Build an array of user data ready to be inserted into the local database.
*/
protected function collectUserData(CurlHandle $curl, HubUser $hubUser): array
protected function collectUserData(CurlHandle $curlHandle, HubUser $hubUser): array
{
return [
'hub_id' => (int) $hubUser->userID,
'hub_id' => $hubUser->userID,
'name' => $hubUser->username,
'email' => Str::lower($hubUser->email),
'password' => $this->cleanPasswordHash($hubUser->password),
'about' => $this->fetchUserAbout($hubUser->userID),
'profile_photo_path' => $this->fetchUserAvatar($curl, $hubUser),
'cover_photo_path' => $this->fetchUserCoverPhoto($curl, $hubUser),
'profile_photo_path' => $this->fetchUserAvatar($curlHandle, $hubUser),
'cover_photo_path' => $this->fetchUserCoverPhoto($curlHandle, $hubUser),
'created_at' => $this->cleanRegistrationDate($hubUser->registrationDate),
'updated_at' => now('UTC')->toDateTimeString(),
];
@ -432,16 +438,16 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
{
// Alright, hear me out... Shut up.
$converter = new HtmlConverter;
$htmlConverter = new HtmlConverter;
$clean = Purify::clean($dirty);
return $converter->convert($clean);
return $htmlConverter->convert($clean);
}
/**
* Fetch the user avatar from the Hub and store it anew.
*/
protected function fetchUserAvatar(CurlHandle $curl, HubUser $hubUser): string
protected function fetchUserAvatar(CurlHandle $curlHandle, HubUser $hubUser): string
{
// Fetch the user's avatar data from the temporary table.
$avatar = DB::table('temp_user_avatar')->where('userID', $hubUser->userID)->first();
@ -450,18 +456,18 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
return '';
}
$hashShort = substr($avatar->fileHash, 0, 2);
$hashShort = substr((string) $avatar->fileHash, 0, 2);
$fileName = $avatar->fileHash.'.'.$avatar->avatarExtension;
$hubUrl = 'https://hub.sp-tarkov.com/images/avatars/'.$hashShort.'/'.$avatar->avatarID.'-'.$fileName;
$relativePath = User::profilePhotoStoragePath().'/'.$fileName;
return $this->fetchAndStoreImage($curl, $hubUrl, $relativePath);
return $this->fetchAndStoreImage($curlHandle, $hubUrl, $relativePath);
}
/**
* Fetch and store an image from the Hub.
*/
protected function fetchAndStoreImage(CurlHandle $curl, string $hubUrl, string $relativePath): string
protected function fetchAndStoreImage(CurlHandle $curlHandle, string $hubUrl, string $relativePath): string
{
// Determine the disk to use based on the environment.
$disk = match (config('app.env')) {
@ -475,11 +481,11 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
}
// Download the image using the cURL handler.
curl_setopt($curl, CURLOPT_URL, $hubUrl);
$image = curl_exec($curl);
curl_setopt($curlHandle, CURLOPT_URL, $hubUrl);
$image = curl_exec($curlHandle);
if ($image === false) {
Log::error('There was an error attempting to download the image. cURL error: '.curl_error($curl));
Log::error('There was an error attempting to download the image. cURL error: '.curl_error($curlHandle));
return '';
}
@ -493,9 +499,9 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
/**
* Fetch the user avatar from the Hub and store it anew.
*/
protected function fetchUserCoverPhoto(CurlHandle $curl, HubUser $hubUser): string
protected function fetchUserCoverPhoto(CurlHandle $curlHandle, HubUser $hubUser): string
{
if (empty($hubUser->coverPhotoHash) || empty($hubUser->coverPhotoExtension)) {
if ($hubUser->coverPhotoHash === null || $hubUser->coverPhotoHash === '' || $hubUser->coverPhotoExtension === null || $hubUser->coverPhotoExtension === '') {
return '';
}
@ -504,7 +510,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
$hubUrl = 'https://hub.sp-tarkov.com/images/coverPhotos/'.$hashShort.'/'.$hubUser->userID.'-'.$fileName;
$relativePath = 'user-covers/'.$fileName;
return $this->fetchAndStoreImage($curl, $hubUrl, $relativePath);
return $this->fetchAndStoreImage($curlHandle, $hubUrl, $relativePath);
}
/**
@ -529,7 +535,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
{
if ($hubUser->banned) {
return [
'hub_id' => (int) $hubUser->userID,
'hub_id' => $hubUser->userID,
'comment' => $hubUser->banReason ?? '',
'expired_at' => $this->cleanUnbannedAtDate($hubUser->banExpires),
];
@ -572,7 +578,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
}
return $date->toDateTimeString();
} catch (\Exception $e) {
} catch (Exception) {
// If the date is not valid, return null
return null;
}
@ -585,7 +591,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
{
if ($hubUser->rankID && $hubUser->rankTitle) {
return [
'hub_id' => (int) $hubUser->userID,
'hub_id' => $hubUser->userID,
'title' => $hubUser->rankTitle,
];
}
@ -598,7 +604,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
*/
protected function upsertUsers(array $usersData): void
{
if (! empty($usersData)) {
if ($usersData !== []) {
DB::table('users')->upsert($usersData, ['hub_id'], [
'name',
'email',
@ -677,7 +683,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
DB::connection('mysql_hub')
->table('wcf1_user_follow')
->select(['followID', 'userID', 'followUserID', 'time'])
->chunkById(100, function (Collection $follows) use (&$followsGroupedByFollower) {
->chunkById(100, function (Collection $follows) use (&$followsGroupedByFollower): void {
foreach ($follows as $follow) {
$followerId = User::whereHubId($follow->userID)->value('id');
$followingId = User::whereHubId($follow->followUserID)->value('id');
@ -708,7 +714,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
{
DB::connection('mysql_hub')
->table('filebase1_license')
->chunkById(100, function (Collection $licenses) {
->chunkById(100, function (Collection $licenses): void {
$insertData = [];
foreach ($licenses as $license) {
@ -719,7 +725,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
];
}
if (! empty($insertData)) {
if ($insertData !== []) {
DB::table('licenses')->upsert($insertData, ['hub_id'], ['name', 'link']);
}
}, 'licenseID');
@ -745,7 +751,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
$response = curl_exec($ch);
if (curl_errno($ch)) {
if (curl_errno($ch) !== 0) {
throw new Exception('cURL Error: '.curl_error($ch));
}
@ -757,21 +763,19 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
throw new Exception('JSON Decode Error: '.json_last_error_msg());
}
if (empty($response)) {
if ($response === []) {
throw new Exception('No version data found in the GitHub API response.');
}
// Filter out drafts and pre-releases.
$response = array_filter($response, function ($release) {
return ! $release['draft'] && ! $release['prerelease'];
});
$response = array_filter($response, fn (array $release): bool => ! $release['draft'] && ! $release['prerelease']);
if (empty($response)) {
if ($response === []) {
throw new Exception('No finalized versions found after filtering drafts and pre-releases.');
}
// Ensure that each of the tag_name values has any 'v' prefix trimmed.
$response = array_map(function ($release) {
$response = array_map(function (array $release) {
$release['tag_name'] = Str::of($release['tag_name'])->ltrim('v')->toString();
return $release;
@ -821,7 +825,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
protected function getLatestVersion(array $versions): string
{
$semanticVersions = array_map(
fn ($version) => $this->extractSemanticVersion($version['tag_name']),
fn ($version): ?string => $this->extractSemanticVersion($version['tag_name']),
$versions
);
@ -876,7 +880,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
$major = (int) $major;
$minor = (int) $minor;
if ($major == $currentMajor) {
if ($major === $currentMajor) {
$difference = $currentMinor - $minor;
return match ($difference) {
@ -903,7 +907,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
DB::connection('mysql_hub')
->table('filebase1_file')
->chunkById(100, function (Collection $mods) use ($curl) {
->chunkById(100, function (Collection $mods) use ($curl): void {
foreach ($mods as $mod) {
// Fetch any additional authors for the mod.
@ -1006,10 +1010,10 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
/**
* Fetch the mod thumbnail from the Hub and store it anew.
*/
protected function fetchModThumbnail(CurlHandle $curl, string $fileID, string $thumbnailHash, string $thumbnailExtension): string
protected function fetchModThumbnail(CurlHandle $curlHandle, string $fileID, string $thumbnailHash, string $thumbnailExtension): string
{
// If any of the required fields are empty, return an empty string.
if (empty($fileID) || empty($thumbnailHash) || empty($thumbnailExtension)) {
if ($fileID === '' || $fileID === '0' || ($thumbnailHash === '' || $thumbnailHash === '0') || ($thumbnailExtension === '' || $thumbnailExtension === '0')) {
return '';
}
@ -1019,7 +1023,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
$hubUrl = 'https://hub.sp-tarkov.com/files/images/file/'.$hashShort.'/'.$fileName;
$relativePath = 'mods/'.$fileName;
return $this->fetchAndStoreImage($curl, $hubUrl, $relativePath);
return $this->fetchAndStoreImage($curlHandle, $hubUrl, $relativePath);
}
/**
@ -1029,7 +1033,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
{
DB::connection('mysql_hub')
->table('filebase1_file_version')
->chunkById(500, function (Collection $versions) {
->chunkById(500, function (Collection $versions): void {
foreach ($versions as $version) {
$versionContent = DB::table('temp_file_version_content')
@ -1065,7 +1069,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
try {
$modVersion = new Version($version->versionNumber);
} catch (InvalidVersionNumberException $e) {
} catch (InvalidVersionNumberException) {
$modVersion = new Version('0.0.0');
}
@ -1123,7 +1127,7 @@ class ImportHubDataJob implements ShouldBeUnique, ShouldQueue
/**
* The job failed to process.
*/
public function failed(Throwable $exception): void
public function failed(Throwable $throwable): void
{
// Explicitly drop the temporary tables.
DB::unprepared('DROP TEMPORARY TABLE IF EXISTS temp_user_avatar');

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Jobs;
use App\Models\ModVersion;
@ -13,7 +15,10 @@ use Illuminate\Queue\SerializesModels;
class ResolveDependenciesJob implements ShouldBeUnique, ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
/**
* Resolve the SPT versions for each of the mod versions.

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Jobs;
use App\Models\ModVersion;
@ -13,7 +15,10 @@ use Illuminate\Queue\SerializesModels;
class ResolveSptVersionsJob implements ShouldBeUnique, ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
/**
* Resolve the SPT versions for each of the mod versions.

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Jobs;
use App\Models\SptVersion;
@ -12,14 +14,17 @@ use Illuminate\Queue\SerializesModels;
class SptVersionModCountsJob implements ShouldBeUnique, ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
/**
* Recalculate the mod counts for each SPT version.
*/
public function handle(): void
{
SptVersion::all()->each(function (SptVersion $sptVersion) {
SptVersion::all()->each(function (SptVersion $sptVersion): void {
$sptVersion->updateModCount();
});
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Jobs;
use App\Models\Mod;
@ -11,14 +13,17 @@ use Illuminate\Queue\SerializesModels;
class UpdateModDownloadsJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
/**
* Recalculate the total download counts for each mod.
*/
public function handle(): void
{
Mod::with('versions')->chunk(100, function ($mods) {
Mod::with('versions')->chunk(100, function ($mods): void {
foreach ($mods as $mod) {
$mod->calculateDownloads();
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Livewire;
use App\Models\Mod;
@ -78,8 +80,6 @@ class GlobalSearch extends Component
*/
protected function countTotalResults(array $results): int
{
return collect($results)->reduce(function (int $carry, Collection $result) {
return $carry + $result->count();
}, 0);
return collect($results)->reduce(fn (int $carry, Collection $result): int => $carry + $result->count(), 0);
}
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Livewire\Mod;
use App\Http\Filters\ModFilter;
@ -72,11 +74,9 @@ class Listing extends Component
*/
public function mount(): void
{
$this->activeSptVersions = $this->activeSptVersions ?? Cache::remember('active-spt-versions', 60 * 60, function () {
return SptVersion::getVersionsForLastThreeMinors();
});
$this->activeSptVersions ??= Cache::remember('active-spt-versions', 60 * 60, fn (): Collection => SptVersion::getVersionsForLastThreeMinors());
$this->sptVersions = $this->sptVersions ?? $this->getDefaultSptVersions();
$this->sptVersions ??= $this->getDefaultSptVersions();
}
/**
@ -92,9 +92,7 @@ class Listing extends Component
*/
public function getLatestMinorVersions(): Collection
{
return $this->activeSptVersions->filter(function (SptVersion $sptVersion) {
return $sptVersion->isLatestMinor();
});
return $this->activeSptVersions->filter(fn (SptVersion $sptVersion): bool => $sptVersion->isLatestMinor());
}
/**
@ -112,11 +110,11 @@ class Listing extends Component
'sptVersions' => $this->sptVersions,
];
$mods = (new ModFilter($filters))->apply()->paginate($this->perPage);
$lengthAwarePaginator = (new ModFilter($filters))->apply()->paginate($this->perPage);
$this->redirectOutOfBoundsPage($mods);
$this->redirectOutOfBoundsPage($lengthAwarePaginator);
return view('livewire.mod.listing', compact('mods'));
return view('livewire.mod.listing', ['mods' => $mods]);
}
/**
@ -140,10 +138,10 @@ class Listing extends Component
/**
* Check if the current page is greater than the last page. Redirect if it is.
*/
private function redirectOutOfBoundsPage(LengthAwarePaginator $mods): void
private function redirectOutOfBoundsPage(LengthAwarePaginator $lengthAwarePaginator): void
{
if ($mods->currentPage() > $mods->lastPage()) {
$this->redirectRoute('mods', ['page' => $mods->lastPage()]);
if ($lengthAwarePaginator->currentPage() > $lengthAwarePaginator->lastPage()) {
$this->redirectRoute('mods', ['page' => $lengthAwarePaginator->lastPage()]);
}
}
@ -165,13 +163,13 @@ class Listing extends Component
{
$count = 0;
if ($this->query !== '') {
$count++;
++$count;
}
if ($this->featured !== 'include') {
$count++;
}
$count += count($this->sptVersions);
return $count;
if ($this->featured !== 'include') {
++$count;
}
return $count + count($this->sptVersions);
}
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Livewire\Profile;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Livewire\Profile;
use App\Actions\Fortify\PasswordValidationRules;
@ -21,14 +23,14 @@ class UpdatePasswordForm extends JetstreamUpdatePasswordForm
* without needing to provide their current password. This is useful for users that have been created using OAuth.
*/
#[Override]
public function updatePassword(UpdatesUserPasswords $updater): void
public function updatePassword(UpdatesUserPasswords $updatesUserPasswords): void
{
$this->resetErrorBag();
$user = Auth::user();
if ($user->password !== null) {
parent::updatePassword($updater);
parent::updatePassword($updatesUserPasswords);
} else {
// User has a null password. Allow them to set a new password without their current password.

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Livewire\Profile;
use Illuminate\Http\RedirectResponse;
@ -7,6 +9,7 @@ use Illuminate\Support\Facades\Auth;
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation;
use Laravel\Jetstream\Http\Livewire\UpdateProfileInformationForm;
use Livewire\Features\SupportRedirects\Redirector;
use Override;
class UpdateProfileForm extends UpdateProfileInformationForm
{
@ -38,11 +41,12 @@ class UpdateProfileForm extends UpdateProfileInformationForm
/**
* Update the user's profile information.
*/
public function updateProfileInformation(UpdatesUserProfileInformation $updater): RedirectResponse|Redirector|null
#[Override]
public function updateProfileInformation(UpdatesUserProfileInformation $updatesUserProfileInformation): RedirectResponse|Redirector|null
{
$this->resetErrorBag();
$updater->update(
$updatesUserProfileInformation->update(
Auth::user(),
$this->photo || $this->cover
? array_merge($this->state, array_filter([
@ -51,7 +55,7 @@ class UpdateProfileForm extends UpdateProfileInformationForm
])) : $this->state
);
if (isset($this->photo) || isset($this->cover)) {
if ($this->photo !== null || $this->cover !== null) {
return redirect()->route('profile.show');
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Livewire\User;
use Illuminate\View\View;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Livewire\User;
use App\Models\User;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Livewire\User;
use App\Models\User;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Models;
use App\Http\Filters\V1\QueryFilter;
@ -7,6 +9,7 @@ use App\Models\Scopes\DisabledScope;
use App\Models\Scopes\PublishedScope;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Casts\Attribute;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
@ -18,6 +21,7 @@ use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Laravel\Scout\Searchable;
use Override;
class Mod extends Model
{
@ -28,6 +32,7 @@ class Mod extends Model
/**
* Post boot method to configure the model.
*/
#[Override]
protected static function booted(): void
{
static::addGlobalScope(new DisabledScope);
@ -162,15 +167,10 @@ class Mod extends Model
}
// Ensure the latest SPT version is within the last three minor versions.
$activeSptVersions = Cache::remember('active-spt-versions', 60 * 60, function () {
return SptVersion::getVersionsForLastThreeMinors();
});
if (! in_array($this->latestVersion->latestSptVersion->version, $activeSptVersions->pluck('version')->toArray())) {
return false;
}
$activeSptVersions = Cache::remember('active-spt-versions', 60 * 60, fn (): Collection => SptVersion::getVersionsForLastThreeMinors());
// All conditions are met; the mod should be searchable.
return true;
return in_array($this->latestVersion->latestSptVersion->version, $activeSptVersions->pluck('version')->toArray());
}
/**
@ -196,11 +196,9 @@ class Mod extends Model
*/
public function thumbnailUrl(): Attribute
{
return Attribute::get(function (): string {
return $this->thumbnail
? Storage::disk($this->thumbnailDisk())->url($this->thumbnail)
: '';
});
return Attribute::get(fn (): string => $this->thumbnail
? Storage::disk($this->thumbnailDisk())->url($this->thumbnail)
: '');
}
/**
@ -217,9 +215,9 @@ class Mod extends Model
/**
* Scope a query by applying QueryFilter filters.
*/
public function scopeFilter(Builder $builder, QueryFilter $filters): Builder
public function scopeFilter(Builder $builder, QueryFilter $queryFilter): Builder
{
return $filters->apply($builder);
return $queryFilter->apply($builder);
}
/**

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\Model;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Models;
use App\Exceptions\InvalidVersionNumberException;
@ -13,6 +15,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\HasOneThrough;
use Illuminate\Database\Eloquent\SoftDeletes;
use Override;
class ModVersion extends Model
{
@ -27,26 +30,27 @@ class ModVersion extends Model
/**
* Post boot method to configure the model.
*/
#[Override]
protected static function booted(): void
{
static::addGlobalScope(new DisabledScope);
static::addGlobalScope(new PublishedScope);
static::saving(function (ModVersion $model) {
static::saving(function (ModVersion $modVersion): void {
// Extract the version sections from the version string.
try {
$version = new Version($model->version);
$version = new Version($modVersion->version);
$model->version_major = $version->getMajor();
$model->version_minor = $version->getMinor();
$model->version_patch = $version->getPatch();
$model->version_pre_release = $version->getPreRelease();
} catch (InvalidVersionNumberException $e) {
$model->version_major = 0;
$model->version_minor = 0;
$model->version_patch = 0;
$model->version_pre_release = '';
$modVersion->version_major = $version->getMajor();
$modVersion->version_minor = $version->getMinor();
$modVersion->version_patch = $version->getPatch();
$modVersion->version_pre_release = $version->getPreRelease();
} catch (InvalidVersionNumberException) {
$modVersion->version_major = 0;
$modVersion->version_minor = 0;
$modVersion->version_patch = 0;
$modVersion->version_pre_release = '';
}
});
}
@ -93,7 +97,7 @@ class ModVersion extends Model
{
return $this->belongsToMany(ModVersion::class, 'mod_resolved_dependencies', 'mod_version_id', 'resolved_mod_version_id')
->withPivot('dependency_id')
->join('mod_versions as latest_versions', function ($join) {
->join('mod_versions as latest_versions', function ($join): void {
$join->on('latest_versions.id', '=', 'mod_versions.id')
->whereRaw('latest_versions.version = (SELECT MAX(mv.version) FROM mod_versions mv WHERE mv.mod_id = mod_versions.mod_id)');
})
@ -144,7 +148,7 @@ class ModVersion extends Model
*/
public function incrementDownloads(): int
{
$this->downloads++;
++$this->downloads;
$this->save();
// Recalculate the total download count for this mod.

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\Relations\Pivot;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Models\Scopes;
use Illuminate\Database\Eloquent\Builder;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Models\Scopes;
use Illuminate\Database\Eloquent\Builder;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Models;
use App\Exceptions\InvalidVersionNumberException;
@ -10,6 +12,7 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Facades\Cache;
use Override;
class SptVersion extends Model
{
@ -56,12 +59,10 @@ class SptVersion extends Model
->orderByDesc('version_minor')
->limit(3)
->get()
->map(function (SptVersion $version) {
return [
'major' => (int) $version->version_major,
'minor' => (int) $version->version_minor,
];
})
->map(fn (SptVersion $sptVersion): array => [
'major' => (int) $sptVersion->version_major,
'minor' => (int) $sptVersion->version_minor,
])
->toArray();
}
@ -77,7 +78,7 @@ class SptVersion extends Model
// Perform the regex match to capture the version sections, including the possible preRelease section.
preg_match('/^(\d+)(?:\.(\d+))?(?:\.(\d+))?(?:-([a-zA-Z0-9]+))?$/', $version, $matches);
if (! $matches) {
if ($matches === []) {
throw new InvalidVersionNumberException('Invalid SPT version number: '.$version);
}
@ -92,22 +93,23 @@ class SptVersion extends Model
/**
* Called when the model is booted.
*/
#[Override]
protected static function booted(): void
{
static::saving(function (SptVersion $model) {
static::saving(function (SptVersion $sptVersion): void {
// Extract the version sections from the version string.
try {
$version = new Version($model->version);
$version = new Version($sptVersion->version);
$model->version_major = $version->getMajor();
$model->version_minor = $version->getMinor();
$model->version_patch = $version->getPatch();
$model->version_pre_release = $version->getPreRelease();
} catch (InvalidVersionNumberException $e) {
$model->version_major = 0;
$model->version_minor = 0;
$model->version_patch = 0;
$model->version_pre_release = '';
$sptVersion->version_major = $version->getMajor();
$sptVersion->version_minor = $version->getMinor();
$sptVersion->version_patch = $version->getPatch();
$sptVersion->version_pre_release = $version->getPreRelease();
} catch (InvalidVersionNumberException) {
$sptVersion->version_major = 0;
$sptVersion->version_minor = 0;
$sptVersion->version_patch = 0;
$sptVersion->version_pre_release = '';
}
});
}
@ -152,7 +154,7 @@ class SptVersion extends Model
{
$latestVersion = self::getLatest();
if (! $latestVersion) {
if (! $latestVersion instanceof \App\Models\SptVersion) {
return false;
}
@ -166,13 +168,11 @@ class SptVersion extends Model
*/
public static function getLatest(): ?SptVersion
{
return Cache::remember('latest_spt_version', 300, function () {
return SptVersion::select(['version', 'version_major', 'version_minor', 'version_patch', 'version_pre_release'])
->orderByDesc('version_major')
->orderByDesc('version_minor')
->orderByDesc('version_patch')
->first();
});
return Cache::remember('latest_spt_version', 300, fn () => SptVersion::select(['version', 'version_major', 'version_minor', 'version_patch', 'version_pre_release'])
->orderByDesc('version_major')
->orderByDesc('version_minor')
->orderByDesc('version_patch')
->first());
}
/**

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Models;
use App\Http\Filters\V1\QueryFilter;
@ -21,6 +23,7 @@ use Laravel\Jetstream\HasProfilePhoto;
use Laravel\Sanctum\HasApiTokens;
use Laravel\Scout\Searchable;
use Mchev\Banhammer\Traits\Bannable;
use SensitiveParameter;
class User extends Authenticatable implements MustVerifyEmail
{
@ -169,7 +172,7 @@ class User extends Authenticatable implements MustVerifyEmail
/**
* Overwritten to instead use the queued version of the ResetPassword notification.
*/
public function sendPasswordResetNotification(#[\SensitiveParameter] $token): void
public function sendPasswordResetNotification(#[SensitiveParameter] $token): void
{
$this->notify(new ResetPassword($token));
}
@ -196,9 +199,9 @@ class User extends Authenticatable implements MustVerifyEmail
/**
* Assign a role to the user.
*/
public function assignRole(UserRole $role): bool
public function assignRole(UserRole $userRole): bool
{
$this->role()->associate($role);
$this->role()->associate($userRole);
return $this->save();
}
@ -216,9 +219,9 @@ class User extends Authenticatable implements MustVerifyEmail
/**
* Scope a query by applying QueryFilter filters.
*/
public function scopeFilter(Builder $builder, QueryFilter $filters): Builder
public function scopeFilter(Builder $builder, QueryFilter $queryFilter): Builder
{
return $filters->apply($builder);
return $queryFilter->apply($builder);
}
/**

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\Factories\HasFactory;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Notifications;
use Illuminate\Auth\Notifications\ResetPassword as OriginalResetPassword;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Notifications;
use Illuminate\Auth\Notifications\VerifyEmail as OriginalVerifyEmail;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Observers;
use App\Models\ModDependency;
@ -7,12 +9,7 @@ use App\Services\DependencyVersionService;
class ModDependencyObserver
{
protected DependencyVersionService $dependencyVersionService;
public function __construct(DependencyVersionService $dependencyVersionService)
{
$this->dependencyVersionService = $dependencyVersionService;
}
public function __construct(protected DependencyVersionService $dependencyVersionService) {}
/**
* Handle the ModDependency "saved" event.

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Observers;
use App\Models\Mod;
@ -7,13 +9,7 @@ use App\Services\DependencyVersionService;
class ModObserver
{
protected DependencyVersionService $dependencyVersionService;
public function __construct(
DependencyVersionService $dependencyVersionService,
) {
$this->dependencyVersionService = $dependencyVersionService;
}
public function __construct(protected DependencyVersionService $dependencyVersionService) {}
/**
* Handle the Mod "saved" event.

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Observers;
use App\Models\ModVersion;
@ -8,17 +10,7 @@ use App\Services\SptVersionService;
class ModVersionObserver
{
protected DependencyVersionService $dependencyVersionService;
protected SptVersionService $sptVersionService;
public function __construct(
DependencyVersionService $dependencyVersionService,
SptVersionService $sptVersionService,
) {
$this->dependencyVersionService = $dependencyVersionService;
$this->sptVersionService = $sptVersionService;
}
public function __construct(protected DependencyVersionService $dependencyVersionService, protected SptVersionService $sptVersionService) {}
/**
* Handle the ModVersion "saved" event.

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Observers;
use App\Models\ModVersion;
@ -7,12 +9,7 @@ use App\Services\SptVersionService;
class SptVersionObserver
{
protected SptVersionService $sptVersionService;
public function __construct(SptVersionService $sptVersionService)
{
$this->sptVersionService = $sptVersionService;
}
public function __construct(protected SptVersionService $sptVersionService) {}
/**
* Handle the SptVersion "saved" event.

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Policies;
use App\Models\Mod;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Policies;
use App\Models\ModVersion;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Policies;
use App\Models\OAuthConnection;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Policies;
use App\Models\User;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Providers;
use App\Livewire\Profile\UpdatePasswordForm;
@ -19,6 +21,7 @@ use Illuminate\Support\Facades\Gate;
use Illuminate\Support\Number;
use Illuminate\Support\ServiceProvider;
use Livewire\Livewire;
use Override;
use SocialiteProviders\Discord\Provider;
use SocialiteProviders\Manager\SocialiteWasCalled;
@ -27,6 +30,7 @@ class AppServiceProvider extends ServiceProvider
/**
* Register any application services.
*/
#[Override]
public function register(): void
{
//
@ -54,13 +58,11 @@ class AppServiceProvider extends ServiceProvider
$this->registerLivewireOverrides();
// This gate determines who can access the Pulse dashboard.
Gate::define('viewPulse', function (User $user) {
return $user->isAdmin();
});
Gate::define('viewPulse', fn (User $user): bool => $user->isAdmin());
// Register the Discord socialite provider.
Event::listen(function (SocialiteWasCalled $event) {
$event->extendSocialite('discord', Provider::class);
Event::listen(function (SocialiteWasCalled $socialiteWasCalled): void {
$socialiteWasCalled->extendSocialite('discord', Provider::class);
});
}
@ -81,14 +83,12 @@ class AppServiceProvider extends ServiceProvider
private function registerNumberMacros(): void
{
// Format download numbers.
Number::macro('downloads', function (int|float $number) {
return Number::forHumans(
$number,
$number > 1000000 ? 2 : ($number > 1000 ? 1 : 0),
maxPrecision: null,
abbreviate: true
);
});
Number::macro('downloads', fn (int|float $number) => Number::forHumans(
$number,
$number > 1000000 ? 2 : ($number > 1000 ? 1 : 0),
maxPrecision: null,
abbreviate: true
));
}
/**
@ -97,10 +97,11 @@ class AppServiceProvider extends ServiceProvider
private function registerCarbonMacros(): void
{
// Format dates dynamically based on the time passed.
Carbon::macro('dynamicFormat', function (Carbon $date) {
Carbon::macro('dynamicFormat', function (Carbon $date): string {
if ($date->diff(now())->m > 1) {
return $date->format('M jS, Y');
}
if ($date->diff(now())->d === 0) {
return $date->diffForHumans();
}

View File

@ -1,15 +1,18 @@
<?php
declare(strict_types=1);
namespace App\Providers\Filament;
use Filament\Http\Middleware\Authenticate;
use Filament\Http\Middleware\DisableBladeIconComponents;
use Filament\Http\Middleware\DispatchServingFilamentEvent;
use Filament\Pages;
use Filament\Pages\Dashboard;
use Filament\Panel;
use Filament\PanelProvider;
use Filament\Support\Colors\Color;
use Filament\Widgets;
use Filament\Widgets\AccountWidget;
use Filament\Widgets\FilamentInfoWidget;
use Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse;
use Illuminate\Cookie\Middleware\EncryptCookies;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken;
@ -32,12 +35,12 @@ class AdminPanelProvider extends PanelProvider
->discoverResources(in: app_path('Filament/Resources'), for: 'App\\Filament\\Resources')
->discoverPages(in: app_path('Filament/Pages'), for: 'App\\Filament\\Pages')
->pages([
Pages\Dashboard::class,
Dashboard::class,
])
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
->widgets([
Widgets\AccountWidget::class,
Widgets\FilamentInfoWidget::class,
AccountWidget::class,
FilamentInfoWidget::class,
])
->middleware([
EncryptCookies::class,

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Providers;
use App\Actions\Fortify\CreateNewUser;
@ -12,12 +14,14 @@ use Illuminate\Support\Facades\RateLimiter;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
use Laravel\Fortify\Fortify;
use Override;
class FortifyServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
#[Override]
public function register(): void
{
//
@ -39,8 +43,6 @@ class FortifyServiceProvider extends ServiceProvider
return Limit::perMinute(5)->by($throttleKey);
});
RateLimiter::for('two-factor', function (Request $request) {
return Limit::perMinute(5)->by($request->session()->get('login.id'));
});
RateLimiter::for('two-factor', fn (Request $request) => Limit::perMinute(5)->by($request->session()->get('login.id')));
}
}

View File

@ -1,15 +1,19 @@
<?php
declare(strict_types=1);
namespace App\Providers;
use Illuminate\Support\Facades\Gate;
use Laravel\Horizon\HorizonApplicationServiceProvider;
use Override;
class HorizonServiceProvider extends HorizonApplicationServiceProvider
{
/**
* Bootstrap any application services.
*/
#[Override]
public function boot(): void
{
parent::boot();
@ -24,10 +28,9 @@ class HorizonServiceProvider extends HorizonApplicationServiceProvider
*
* This gate determines who can access Horizon in non-local environments.
*/
#[Override]
protected function gate(): void
{
Gate::define('viewHorizon', function ($user) {
return $user->isAdmin();
});
Gate::define('viewHorizon', fn ($user) => $user->isAdmin());
}
}

View File

@ -1,16 +1,20 @@
<?php
declare(strict_types=1);
namespace App\Providers;
use App\Actions\Jetstream\DeleteUser;
use Illuminate\Support\ServiceProvider;
use Laravel\Jetstream\Jetstream;
use Override;
class JetstreamServiceProvider extends ServiceProvider
{
/**
* Register any application services.
*/
#[Override]
public function register(): void
{
//

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Services;
use App\Models\ModVersion;
@ -32,9 +34,7 @@ class DependencyVersionService
$dependentModVersions = $dependency->dependentMod->versions()->get();
// Filter the dependent mod versions to find the ones that satisfy the dependency constraint.
$matchedVersions = $dependentModVersions->filter(function ($version) use ($dependency) {
return Semver::satisfies($version->version, $dependency->constraint);
});
$matchedVersions = $dependentModVersions->filter(fn ($version) => Semver::satisfies($version->version, $dependency->constraint));
// Map the matched versions to the sync data.
foreach ($matchedVersions as $matchedVersion) {

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Services;
use App\Models\ModVersion;

View File

@ -1,10 +1,13 @@
<?php
declare(strict_types=1);
namespace App\Support;
use App\Exceptions\InvalidVersionNumberException;
use Stringable;
class Version
class Version implements Stringable
{
protected int $major = 0;
@ -14,16 +17,13 @@ class Version
protected string $preRelease = '';
protected string $version;
/**
* Constructor.
*
* @throws InvalidVersionNumberException
*/
public function __construct(string $version)
public function __construct(protected string $version)
{
$this->version = $version;
$this->parseVersion();
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Traits;
use Illuminate\Http\JsonResponse;
@ -24,6 +26,7 @@ trait ApiResponses
if ($data) {
$response['data'] = $data;
}
$response['status'] = $code;
return response()->json($response, $code);

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Traits;
use Illuminate\Database\Eloquent\Casts\Attribute;
@ -11,11 +13,11 @@ trait HasCoverPhoto
/**
* Update the user's cover photo.
*/
public function updateCoverPhoto(UploadedFile $cover, string $storagePath = 'cover-photos'): void
public function updateCoverPhoto(UploadedFile $uploadedFile, string $storagePath = 'cover-photos'): void
{
tap($this->cover_photo_path, function ($previous) use ($cover, $storagePath) {
tap($this->cover_photo_path, function ($previous) use ($uploadedFile, $storagePath): void {
$this->forceFill([
'cover_photo_path' => $cover->storePublicly(
'cover_photo_path' => $uploadedFile->storePublicly(
$storagePath, ['disk' => $this->coverPhotoDisk()]
),
])->save();

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\Traits\V1;
use Illuminate\Database\Eloquent\Builder;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\View\Components;
use Illuminate\View\Component;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\View\Components;
use Illuminate\View\Component;

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
namespace App\View\Components;
use App\Models\Mod;
@ -36,18 +38,16 @@ class HomepageMods extends Component
*/
private function fetchFeaturedMods(): Collection
{
return Cache::flexible('homepage-featured-mods', [5, 10], function () {
return Mod::whereFeatured(true)
->with([
'latestVersion',
'latestVersion.latestSptVersion',
'users:id,name',
'license:id,name,link',
])
->inRandomOrder()
->limit(6)
->get();
});
return Cache::flexible('homepage-featured-mods', [5, 10], fn () => Mod::whereFeatured(true)
->with([
'latestVersion',
'latestVersion.latestSptVersion',
'users:id,name',
'license:id,name,link',
])
->inRandomOrder()
->limit(6)
->get());
}
/**
@ -55,17 +55,15 @@ class HomepageMods extends Component
*/
private function fetchLatestMods(): Collection
{
return Cache::flexible('homepage-latest-mods', [5, 10], function () {
return Mod::orderByDesc('created_at')
->with([
'latestVersion',
'latestVersion.latestSptVersion',
'users:id,name',
'license:id,name,link',
])
->limit(6)
->get();
});
return Cache::flexible('homepage-latest-mods', [5, 10], fn () => Mod::orderByDesc('created_at')
->with([
'latestVersion',
'latestVersion.latestSptVersion',
'users:id,name',
'license:id,name,link',
])
->limit(6)
->get());
}
/**
@ -73,16 +71,14 @@ class HomepageMods extends Component
*/
private function fetchUpdatedMods(): Collection
{
return Cache::flexible('homepage-updated-mods', [5, 10], function () {
return Mod::orderByDesc('updated_at')
->with([
'latestUpdatedVersion',
'latestUpdatedVersion.latestSptVersion',
'users:id,name',
'license:id,name,link',
])
->limit(6)
->get();
});
return Cache::flexible('homepage-updated-mods', [5, 10], fn () => Mod::orderByDesc('updated_at')
->with([
'latestUpdatedVersion',
'latestUpdatedVersion.latestSptVersion',
'users:id,name',
'license:id,name,link',
])
->limit(6)
->get());
}
}

View File

@ -1,5 +1,7 @@
<?php
declare(strict_types=1);
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
use Illuminate\Foundation\Configuration\Middleware;
@ -12,17 +14,17 @@ return Application::configure(basePath: dirname(__DIR__))
api: __DIR__.'/../routes/api.php',
commands: __DIR__.'/../routes/console.php',
health: '/up',
then: function () {
then: function (): void {
Route::middleware('api')
->prefix('api/v0')
->name('api.v0.')
->group(base_path('routes/api_v0.php'));
},
)
->withMiddleware(function (Middleware $middleware) {
->withMiddleware(function (Middleware $middleware): void {
$middleware->append(IPBanned::class);
})
->withExceptions(function (Exceptions $exceptions) {
->withExceptions(function (Exceptions $exceptions): void {
//
})
->create();

View File

@ -1,10 +1,19 @@
<?php
declare(strict_types=1);
use App\Providers\AppServiceProvider;
use App\Providers\Filament\AdminPanelProvider;
use App\Providers\FortifyServiceProvider;
use App\Providers\HorizonServiceProvider;
use App\Providers\JetstreamServiceProvider;
use SocialiteProviders\Manager\ServiceProvider;
return [
App\Providers\AppServiceProvider::class,
App\Providers\FortifyServiceProvider::class,
App\Providers\HorizonServiceProvider::class,
App\Providers\JetstreamServiceProvider::class,
App\Providers\Filament\AdminPanelProvider::class,
\SocialiteProviders\Manager\ServiceProvider::class,
AppServiceProvider::class,
FortifyServiceProvider::class,
HorizonServiceProvider::class,
JetstreamServiceProvider::class,
AdminPanelProvider::class,
ServiceProvider::class,
];

View File

@ -39,7 +39,7 @@
"mockery/mockery": "^1.6.12",
"nunomaduro/collision": "^8.5",
"pestphp/pest": "^3.7.1",
"rector/rector": "^2.0.6",
"rector/rector": "^2.0",
"spatie/laravel-ignition": "^2.9"
},
"autoload": {

122
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "9328dfa86830ba961319c4df32bac2fb",
"content-hash": "69d42ce1d7d16f80f3280100cef74c4f",
"packages": [
{
"name": "anourvalar/eloquent-serialize",
@ -128,16 +128,16 @@
},
{
"name": "aws/aws-sdk-php",
"version": "3.339.1",
"version": "3.339.2",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "3675e58c8fa971f4b4a24e7b0bee8673bda1ba00"
"reference": "2f4e85dd8466ffe5186887f8f1466a0248c6c094"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/3675e58c8fa971f4b4a24e7b0bee8673bda1ba00",
"reference": "3675e58c8fa971f4b4a24e7b0bee8673bda1ba00",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/2f4e85dd8466ffe5186887f8f1466a0248c6c094",
"reference": "2f4e85dd8466ffe5186887f8f1466a0248c6c094",
"shasum": ""
},
"require": {
@ -220,9 +220,9 @@
"support": {
"forum": "https://github.com/aws/aws-sdk-php/discussions",
"issues": "https://github.com/aws/aws-sdk-php/issues",
"source": "https://github.com/aws/aws-sdk-php/tree/3.339.1"
"source": "https://github.com/aws/aws-sdk-php/tree/3.339.2"
},
"time": "2025-01-28T19:05:47+00:00"
"time": "2025-01-29T19:53:29+00:00"
},
{
"name": "bacon/bacon-qr-code",
@ -7497,16 +7497,16 @@
},
{
"name": "symfony/error-handler",
"version": "v7.2.1",
"version": "v7.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/error-handler.git",
"reference": "6150b89186573046167796fa5f3f76601d5145f8"
"reference": "959a74d044a6db21f4caa6d695648dcb5584cb49"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/error-handler/zipball/6150b89186573046167796fa5f3f76601d5145f8",
"reference": "6150b89186573046167796fa5f3f76601d5145f8",
"url": "https://api.github.com/repos/symfony/error-handler/zipball/959a74d044a6db21f4caa6d695648dcb5584cb49",
"reference": "959a74d044a6db21f4caa6d695648dcb5584cb49",
"shasum": ""
},
"require": {
@ -7552,7 +7552,7 @@
"description": "Provides tools to manage errors and ease debugging PHP code",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/error-handler/tree/v7.2.1"
"source": "https://github.com/symfony/error-handler/tree/v7.2.3"
},
"funding": [
{
@ -7568,7 +7568,7 @@
"type": "tidelift"
}
],
"time": "2024-12-07T08:50:44+00:00"
"time": "2025-01-07T09:39:55+00:00"
},
{
"name": "symfony/event-dispatcher",
@ -7792,16 +7792,16 @@
},
{
"name": "symfony/html-sanitizer",
"version": "v7.2.2",
"version": "v7.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/html-sanitizer.git",
"reference": "f6bc679b024e30f27e33815930a5b8b304c79813"
"reference": "91443febe34cfa5e8e00425f892e6316db95bc23"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/html-sanitizer/zipball/f6bc679b024e30f27e33815930a5b8b304c79813",
"reference": "f6bc679b024e30f27e33815930a5b8b304c79813",
"url": "https://api.github.com/repos/symfony/html-sanitizer/zipball/91443febe34cfa5e8e00425f892e6316db95bc23",
"reference": "91443febe34cfa5e8e00425f892e6316db95bc23",
"shasum": ""
},
"require": {
@ -7841,7 +7841,7 @@
"sanitizer"
],
"support": {
"source": "https://github.com/symfony/html-sanitizer/tree/v7.2.2"
"source": "https://github.com/symfony/html-sanitizer/tree/v7.2.3"
},
"funding": [
{
@ -7857,20 +7857,20 @@
"type": "tidelift"
}
],
"time": "2024-12-30T18:35:15+00:00"
"time": "2025-01-27T11:08:17+00:00"
},
{
"name": "symfony/http-foundation",
"version": "v7.2.2",
"version": "v7.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
"reference": "62d1a43796ca3fea3f83a8470dfe63a4af3bc588"
"reference": "ee1b504b8926198be89d05e5b6fc4c3810c090f0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/62d1a43796ca3fea3f83a8470dfe63a4af3bc588",
"reference": "62d1a43796ca3fea3f83a8470dfe63a4af3bc588",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/ee1b504b8926198be89d05e5b6fc4c3810c090f0",
"reference": "ee1b504b8926198be89d05e5b6fc4c3810c090f0",
"shasum": ""
},
"require": {
@ -7919,7 +7919,7 @@
"description": "Defines an object-oriented layer for the HTTP specification",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/http-foundation/tree/v7.2.2"
"source": "https://github.com/symfony/http-foundation/tree/v7.2.3"
},
"funding": [
{
@ -7935,20 +7935,20 @@
"type": "tidelift"
}
],
"time": "2024-12-30T19:00:17+00:00"
"time": "2025-01-17T10:56:55+00:00"
},
{
"name": "symfony/http-kernel",
"version": "v7.2.2",
"version": "v7.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-kernel.git",
"reference": "3c432966bd8c7ec7429663105f5a02d7e75b4306"
"reference": "caae9807f8e25a9b43ce8cc6fafab6cf91f0cc9b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/3c432966bd8c7ec7429663105f5a02d7e75b4306",
"reference": "3c432966bd8c7ec7429663105f5a02d7e75b4306",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/caae9807f8e25a9b43ce8cc6fafab6cf91f0cc9b",
"reference": "caae9807f8e25a9b43ce8cc6fafab6cf91f0cc9b",
"shasum": ""
},
"require": {
@ -8033,7 +8033,7 @@
"description": "Provides a structured process for converting a Request into a Response",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/http-kernel/tree/v7.2.2"
"source": "https://github.com/symfony/http-kernel/tree/v7.2.3"
},
"funding": [
{
@ -8049,20 +8049,20 @@
"type": "tidelift"
}
],
"time": "2024-12-31T14:59:40+00:00"
"time": "2025-01-29T07:40:13+00:00"
},
{
"name": "symfony/mailer",
"version": "v7.2.0",
"version": "v7.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/mailer.git",
"reference": "e4d358702fb66e4c8a2af08e90e7271a62de39cc"
"reference": "f3871b182c44997cf039f3b462af4a48fb85f9d3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/mailer/zipball/e4d358702fb66e4c8a2af08e90e7271a62de39cc",
"reference": "e4d358702fb66e4c8a2af08e90e7271a62de39cc",
"url": "https://api.github.com/repos/symfony/mailer/zipball/f3871b182c44997cf039f3b462af4a48fb85f9d3",
"reference": "f3871b182c44997cf039f3b462af4a48fb85f9d3",
"shasum": ""
},
"require": {
@ -8113,7 +8113,7 @@
"description": "Helps sending emails",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/mailer/tree/v7.2.0"
"source": "https://github.com/symfony/mailer/tree/v7.2.3"
},
"funding": [
{
@ -8129,20 +8129,20 @@
"type": "tidelift"
}
],
"time": "2024-11-25T15:21:05+00:00"
"time": "2025-01-27T11:08:17+00:00"
},
{
"name": "symfony/mime",
"version": "v7.2.1",
"version": "v7.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/mime.git",
"reference": "7f9617fcf15cb61be30f8b252695ed5e2bfac283"
"reference": "2fc3b4bd67e4747e45195bc4c98bea4628476204"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/mime/zipball/7f9617fcf15cb61be30f8b252695ed5e2bfac283",
"reference": "7f9617fcf15cb61be30f8b252695ed5e2bfac283",
"url": "https://api.github.com/repos/symfony/mime/zipball/2fc3b4bd67e4747e45195bc4c98bea4628476204",
"reference": "2fc3b4bd67e4747e45195bc4c98bea4628476204",
"shasum": ""
},
"require": {
@ -8197,7 +8197,7 @@
"mime-type"
],
"support": {
"source": "https://github.com/symfony/mime/tree/v7.2.1"
"source": "https://github.com/symfony/mime/tree/v7.2.3"
},
"funding": [
{
@ -8213,7 +8213,7 @@
"type": "tidelift"
}
],
"time": "2024-12-07T08:50:44+00:00"
"time": "2025-01-27T11:08:17+00:00"
},
{
"name": "symfony/polyfill-ctype",
@ -8997,16 +8997,16 @@
},
{
"name": "symfony/routing",
"version": "v7.2.0",
"version": "v7.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/routing.git",
"reference": "e10a2450fa957af6c448b9b93c9010a4e4c0725e"
"reference": "ee9a67edc6baa33e5fae662f94f91fd262930996"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/routing/zipball/e10a2450fa957af6c448b9b93c9010a4e4c0725e",
"reference": "e10a2450fa957af6c448b9b93c9010a4e4c0725e",
"url": "https://api.github.com/repos/symfony/routing/zipball/ee9a67edc6baa33e5fae662f94f91fd262930996",
"reference": "ee9a67edc6baa33e5fae662f94f91fd262930996",
"shasum": ""
},
"require": {
@ -9058,7 +9058,7 @@
"url"
],
"support": {
"source": "https://github.com/symfony/routing/tree/v7.2.0"
"source": "https://github.com/symfony/routing/tree/v7.2.3"
},
"funding": [
{
@ -9074,7 +9074,7 @@
"type": "tidelift"
}
],
"time": "2024-11-25T11:08:51+00:00"
"time": "2025-01-17T10:56:55+00:00"
},
{
"name": "symfony/service-contracts",
@ -9495,16 +9495,16 @@
},
{
"name": "symfony/var-dumper",
"version": "v7.2.0",
"version": "v7.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
"reference": "c6a22929407dec8765d6e2b6ff85b800b245879c"
"reference": "82b478c69745d8878eb60f9a049a4d584996f73a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/c6a22929407dec8765d6e2b6ff85b800b245879c",
"reference": "c6a22929407dec8765d6e2b6ff85b800b245879c",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/82b478c69745d8878eb60f9a049a4d584996f73a",
"reference": "82b478c69745d8878eb60f9a049a4d584996f73a",
"shasum": ""
},
"require": {
@ -9558,7 +9558,7 @@
"dump"
],
"support": {
"source": "https://github.com/symfony/var-dumper/tree/v7.2.0"
"source": "https://github.com/symfony/var-dumper/tree/v7.2.3"
},
"funding": [
{
@ -9574,7 +9574,7 @@
"type": "tidelift"
}
],
"time": "2024-11-08T15:48:14+00:00"
"time": "2025-01-17T11:39:41+00:00"
},
{
"name": "tijsverkoyen/css-to-inline-styles",
@ -13957,16 +13957,16 @@
},
{
"name": "symfony/yaml",
"version": "v7.2.0",
"version": "v7.2.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "099581e99f557e9f16b43c5916c26380b54abb22"
"reference": "ac238f173df0c9c1120f862d0f599e17535a87ec"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/099581e99f557e9f16b43c5916c26380b54abb22",
"reference": "099581e99f557e9f16b43c5916c26380b54abb22",
"url": "https://api.github.com/repos/symfony/yaml/zipball/ac238f173df0c9c1120f862d0f599e17535a87ec",
"reference": "ac238f173df0c9c1120f862d0f599e17535a87ec",
"shasum": ""
},
"require": {
@ -14009,7 +14009,7 @@
"description": "Loads and dumps YAML files",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/yaml/tree/v7.2.0"
"source": "https://github.com/symfony/yaml/tree/v7.2.3"
},
"funding": [
{
@ -14025,7 +14025,7 @@
"type": "tidelift"
}
],
"time": "2024-10-23T06:56:12+00:00"
"time": "2025-01-07T12:55:42+00:00"
},
{
"name": "ta-tikoma/phpunit-architecture-test",

Some files were not shown because too many files have changed in this diff Show More