Files

38 lines
935 B
PHP
Raw Permalink Normal View History

2026-10-20 21:09:33 +02:00
<?php
declare(strict_types=1);
namespace Pterodactyl\Http\Requests\Api\Client\Account;
2026-10-20 15:55:48 -04:00
use Illuminate\Http\UploadedFile;
use Pterodactyl\Actions\Users\ReplaceUserAvatar;
2026-10-20 21:09:33 +02:00
use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
2026-10-20 15:55:48 -04:00
use UnexpectedValueException;
2026-10-20 21:09:33 +02:00
class UpdateAvatarRequest extends ClientApiRequest
{
2026-10-20 15:55:48 -04:00
/**
* Users may only upload their own avatar while the panel allows it.
*/
public function authorize(): bool
{
return config()->boolean('pterodactyl.client_features.avatars.enabled') && parent::authorize();
}
/**
* @return ValidationRules
*/
2026-10-20 21:09:33 +02:00
public function rules(): array
{
2026-10-20 15:55:48 -04:00
return ReplaceUserAvatar::rules();
}
public function avatar(): UploadedFile
{
$file = $this->file('avatar');
throw_unless($file instanceof UploadedFile, UnexpectedValueException::class, 'Expected an uploaded avatar.');
return $file;
2026-10-20 21:09:33 +02:00
}
}