php-cs fixes

This commit is contained in:
Matthew Penner 2021-03-05 08:46:14 -07:00
parent d57060dad9
commit 8c8de6ac62
8 changed files with 27 additions and 37 deletions

View file

@ -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.');
}

View file

@ -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

View file

@ -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
{

View file

@ -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.');
}

View file

@ -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',
];
/**

View file

@ -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;

View file

@ -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",

View file

@ -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');