2018-01-13 02:39:15 +00:00
|
|
|
<?php
|
|
|
|
|
2018-01-20 01:58:57 +00:00
|
|
|
namespace Pterodactyl\Http\Requests\Api\Application\Users;
|
2018-01-13 02:39:15 +00:00
|
|
|
|
|
|
|
use Pterodactyl\Models\User;
|
|
|
|
|
|
|
|
class UpdateUserRequest extends StoreUserRequest
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Determine if the requested user exists on the Panel.
|
|
|
|
*
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function resourceExists(): bool
|
|
|
|
{
|
|
|
|
$user = $this->route()->parameter('user');
|
|
|
|
|
|
|
|
return $user instanceof User && $user->exists;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the validation rules for this request.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function rules(): array
|
|
|
|
{
|
|
|
|
$userId = $this->route()->parameter('user')->id;
|
|
|
|
|
|
|
|
return collect(User::getUpdateRulesForId($userId))->only([
|
|
|
|
'external_id',
|
|
|
|
'email',
|
|
|
|
'username',
|
|
|
|
'name_first',
|
|
|
|
'name_last',
|
|
|
|
'password',
|
|
|
|
'language',
|
|
|
|
'root_admin',
|
|
|
|
])->toArray();
|
|
|
|
}
|
|
|
|
}
|