From 8c8de6ac62682790f3c883ac7ea36216cf0522f2 Mon Sep 17 00:00:00 2001 From: Matthew Penner Date: Fri, 5 Mar 2021 08:46:14 -0700 Subject: [PATCH] php-cs fixes --- .../Api/Application/Nodes/NodeController.php | 2 +- .../Api/Application/Roles/RoleController.php | 23 +++-------------- .../Application/Servers/ServerController.php | 25 +++++++++++-------- .../Api/Application/Users/UserController.php | 2 +- app/Models/AdminRole.php | 4 ++- app/Models/User.php | 4 +-- database/Seeders/eggs/rust/egg-rust.json | 2 +- routes/api-application.php | 2 -- 8 files changed, 27 insertions(+), 37 deletions(-) diff --git a/app/Http/Controllers/Api/Application/Nodes/NodeController.php b/app/Http/Controllers/Api/Application/Nodes/NodeController.php index 725dfeda5..9e2ee2b28 100644 --- a/app/Http/Controllers/Api/Application/Nodes/NodeController.php +++ b/app/Http/Controllers/Api/Application/Nodes/NodeController.php @@ -65,7 +65,7 @@ class NodeController extends ApplicationApiController $perPage = $request->query('per_page', 10); if ($perPage < 1) { $perPage = 10; - } else if ($perPage > 100) { + } elseif ($perPage > 100) { throw new BadRequestHttpException('"per_page" query parameter must be below 100.'); } diff --git a/app/Http/Controllers/Api/Application/Roles/RoleController.php b/app/Http/Controllers/Api/Application/Roles/RoleController.php index 25057fb2d..522756bda 100644 --- a/app/Http/Controllers/Api/Application/Roles/RoleController.php +++ b/app/Http/Controllers/Api/Application/Roles/RoleController.php @@ -25,9 +25,6 @@ class RoleController extends ApplicationApiController /** * Returns an array of all roles. * - * @param \Pterodactyl\Http\Requests\Api\Application\Roles\GetRolesRequest $request - * - * @return array * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function index(GetRolesRequest $request): array @@ -40,10 +37,6 @@ class RoleController extends ApplicationApiController /** * Returns a single role. * - * @param \Pterodactyl\Http\Requests\Api\Application\Roles\GetRoleRequest $request - * @param \Pterodactyl\Models\AdminRole $role - * - * @return array * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function view(GetRoleRequest $request, AdminRole $role): array @@ -56,14 +49,14 @@ class RoleController extends ApplicationApiController /** * Creates a new role. * - * @param \Pterodactyl\Http\Requests\Api\Application\Roles\StoreRoleRequest $request - * - * @return \Illuminate\Http\JsonResponse * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function store(StoreRoleRequest $request): JsonResponse { - $role = AdminRole::query()->create($request->validated()); + $data = array_merge($request->validated(), [ + 'sort_id' => 99, + ]); + $role = AdminRole::query()->create($data); return $this->fractal->item($role) ->transformWith($this->getTransformer(AdminRoleTransformer::class)) @@ -73,10 +66,6 @@ class RoleController extends ApplicationApiController /** * Updates a role. * - * @param \Pterodactyl\Http\Requests\Api\Application\Roles\UpdateRoleRequest $request - * @param \Pterodactyl\Models\AdminRole $role - * - * @return array * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function update(UpdateRoleRequest $request, AdminRole $role): array @@ -91,10 +80,6 @@ class RoleController extends ApplicationApiController /** * Deletes a role. * - * @param \Pterodactyl\Http\Requests\Api\Application\Roles\DeleteRoleRequest $request - * @param \Pterodactyl\Models\AdminRole $role - * - * @return \Illuminate\Http\JsonResponse * @throws \Exception */ public function delete(DeleteRoleRequest $request, AdminRole $role): JsonResponse diff --git a/app/Http/Controllers/Api/Application/Servers/ServerController.php b/app/Http/Controllers/Api/Application/Servers/ServerController.php index 9481fe8e3..047b72dcd 100644 --- a/app/Http/Controllers/Api/Application/Servers/ServerController.php +++ b/app/Http/Controllers/Api/Application/Servers/ServerController.php @@ -18,15 +18,8 @@ use Pterodactyl\Http\Controllers\Api\Application\ApplicationApiController; class ServerController extends ApplicationApiController { - /** - * @var \Pterodactyl\Services\Servers\ServerCreationService - */ - private $creationService; - - /** - * @var \Pterodactyl\Services\Servers\ServerDeletionService - */ - private $deletionService; + private ServerCreationService $creationService; + private ServerDeletionService $deletionService; /** * ServerController constructor. @@ -43,13 +36,15 @@ class ServerController extends ApplicationApiController /** * Return all of the servers that currently exist on the Panel. + * + * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function index(GetServersRequest $request): array { $perPage = $request->query('per_page', 10); if ($perPage < 1) { $perPage = 10; - } else if ($perPage > 100) { + } elseif ($perPage > 100) { throw new BadRequestHttpException('"per_page" query parameter must be below 100.'); } @@ -84,6 +79,8 @@ class ServerController extends ApplicationApiController /** * Show a single server transformed for the application API. + * + * @throws \Illuminate\Contracts\Container\BindingResolutionException */ public function view(GetServerRequest $request, Server $server): array { @@ -93,7 +90,15 @@ class ServerController extends ApplicationApiController } /** + * Deletes a server. + * + * @param \Pterodactyl\Http\Requests\Api\Application\Servers\ServerWriteRequest $request + * @param \Pterodactyl\Models\Server $server + * @param string $force + * + * @return \Illuminate\Http\Response * @throws \Pterodactyl\Exceptions\DisplayException + * @throws \Throwable */ public function delete(ServerWriteRequest $request, Server $server, string $force = ''): Response { diff --git a/app/Http/Controllers/Api/Application/Users/UserController.php b/app/Http/Controllers/Api/Application/Users/UserController.php index b6332f252..9e1b87b1b 100644 --- a/app/Http/Controllers/Api/Application/Users/UserController.php +++ b/app/Http/Controllers/Api/Application/Users/UserController.php @@ -72,7 +72,7 @@ class UserController extends ApplicationApiController $perPage = $request->query('per_page', 10); if ($perPage < 1) { $perPage = 10; - } else if ($perPage > 100) { + } elseif ($perPage > 100) { throw new BadRequestHttpException('"per_page" query parameter must be below 100.'); } diff --git a/app/Models/AdminRole.php b/app/Models/AdminRole.php index d022eb7f4..9d7ddb322 100644 --- a/app/Models/AdminRole.php +++ b/app/Models/AdminRole.php @@ -15,7 +15,7 @@ class AdminRole extends Model * The resource name for this model when it is transformed into an * API representation using fractal. */ - const RESOURCE_NAME = 'admin_role'; + public const RESOURCE_NAME = 'admin_role'; /** * The table associated with the model. @@ -32,6 +32,7 @@ class AdminRole extends Model protected $fillable = [ 'name', 'description', + 'sort_id', ]; /** @@ -50,6 +51,7 @@ class AdminRole extends Model public static $validationRules = [ 'name' => 'required|string|max:64', 'description' => 'nullable|string|max:255', + 'sort_id' => 'sometimes|numeric', ]; /** diff --git a/app/Models/User.php b/app/Models/User.php index 59d935d61..65eac44d5 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -25,7 +25,7 @@ use Pterodactyl\Notifications\SendPasswordReset as ResetPasswordNotification; * @property string|null $name_first * @property string|null $name_last * @property string $password - * @property string|null $remeber_token + * @property string|null $remember_token * @property string $language * @property bool $root_admin * @property bool $use_totp @@ -156,7 +156,7 @@ class User extends Model implements { $rules = parent::getRules(); - $rules['language'][] = new In(array_keys((new self())->getAvailableLanguages())); + //$rules['language'][] = new In(array_keys((new self())->getAvailableLanguages())); $rules['username'][] = new Username(); return $rules; diff --git a/database/Seeders/eggs/rust/egg-rust.json b/database/Seeders/eggs/rust/egg-rust.json index 2fef9efda..00523ac17 100644 --- a/database/Seeders/eggs/rust/egg-rust.json +++ b/database/Seeders/eggs/rust/egg-rust.json @@ -121,7 +121,7 @@ "default_value": "CHANGEME", "user_viewable": true, "user_editable": true, - "rules": "required|regex:/^[\w.-]*$/|max:64" + "rules": "required|regex:/^[\\w.-]*$/|max:64" }, { "name": "Save Interval", diff --git a/routes/api-application.php b/routes/api-application.php index fd7253a02..ee7711400 100644 --- a/routes/api-application.php +++ b/routes/api-application.php @@ -140,7 +140,6 @@ Route::group(['prefix' => '/nodes'], function () { | Endpoint: /api/application/roles | */ - Route::group(['prefix' => '/roles'], function () { Route::get('/', 'Roles\RoleController@index'); Route::get('/{role}', 'Roles\RoleController@view'); @@ -198,7 +197,6 @@ Route::group(['prefix' => '/servers'], function () { | Endpoint: /api/application/users | */ - Route::group(['prefix' => '/users'], function () { Route::get('/', 'Users\UserController@index')->name('api.application.users'); Route::get('/{user}', 'Users\UserController@view')->name('api.application.users.view');