misc_pterodactyl-panel/app/Http/Requests/Api/Application/Users/StoreUserRequest.php

55 lines
1.4 KiB
PHP
Raw Normal View History

<?php
2018-01-20 01:58:57 +00:00
namespace Pterodactyl\Http\Requests\Api\Application\Users;
use Pterodactyl\Models\User;
use Pterodactyl\Services\Acl\Api\AdminAcl;
use Pterodactyl\Http\Requests\Api\Application\ApplicationApiRequest;
class StoreUserRequest extends ApplicationApiRequest
{
2021-01-24 01:17:35 +00:00
protected string $resource = AdminAcl::RESOURCE_USERS;
protected int $permission = AdminAcl::WRITE;
2018-02-04 21:38:38 +00:00
public function rules(array $rules = null): array
{
$rules = $rules ?? User::getRules();
2018-02-04 21:38:38 +00:00
$response = collect($rules)->only([
'external_id',
'email',
'username',
'password',
'language',
'admin_role_id',
])->toArray();
2018-02-04 21:38:38 +00:00
$response['first_name'] = $rules['name_first'];
$response['last_name'] = $rules['name_last'];
return $response;
}
2021-01-24 01:17:35 +00:00
public function validated(): array
2018-02-04 21:38:38 +00:00
{
$data = parent::validated();
$data['name_first'] = $data['first_name'];
$data['name_last'] = $data['last_name'];
unset($data['first_name'], $data['last_name']);
return $data;
}
2021-01-24 01:17:35 +00:00
public function attributes(): array
{
return [
'external_id' => 'Third Party Identifier',
'name_first' => 'First Name',
'name_last' => 'Last Name',
'root_admin' => 'Root Administrator Status',
];
}
}