2020-04-04 10:59:25 -07:00
|
|
|
<?php
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2020-04-04 10:59:25 -07:00
|
|
|
namespace Pterodactyl\Http\Requests\Api\Client\Servers\Backups;
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
use Illuminate\Support\Arr;
|
|
|
|
|
use Pterodactyl\Contracts\Http\ClientPermissionsRequest;
|
|
|
|
|
use Pterodactyl\Enum\Permissions;
|
2020-04-04 10:59:25 -07:00
|
|
|
use Pterodactyl\Http\Requests\Api\Client\ClientApiRequest;
|
2026-10-05 18:10:18 -04:00
|
|
|
use Pterodactyl\Support\JsonValueGuard;
|
2020-04-04 10:59:25 -07:00
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
class StoreBackupRequest extends ClientApiRequest implements ClientPermissionsRequest
|
2020-04-04 10:59:25 -07:00
|
|
|
{
|
2022-10-14 10:59:20 -06:00
|
|
|
public function permission(): string
|
2020-04-04 10:59:25 -07:00
|
|
|
{
|
2026-10-05 18:10:18 -04:00
|
|
|
return Permissions::BackupCreate->value;
|
2020-04-04 10:59:25 -07:00
|
|
|
}
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
/**
|
|
|
|
|
* @return ValidationRules
|
|
|
|
|
*/
|
2020-04-04 10:59:25 -07:00
|
|
|
public function rules(): array
|
|
|
|
|
{
|
|
|
|
|
return [
|
2026-10-05 18:10:18 -04:00
|
|
|
'name' => ['nullable', 'string', 'max:191'],
|
|
|
|
|
'is_locked' => ['nullable', 'boolean'],
|
|
|
|
|
'ignored' => ['nullable', 'string'],
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return array{name: string|null, is_locked: bool, ignored: string|null}
|
|
|
|
|
*/
|
|
|
|
|
public function payload(): array
|
|
|
|
|
{
|
|
|
|
|
$data = parent::validated();
|
|
|
|
|
|
|
|
|
|
return [
|
|
|
|
|
'name' => JsonValueGuard::nullableString(Arr::get($data, 'name')),
|
|
|
|
|
'is_locked' => JsonValueGuard::boolean(Arr::get($data, 'is_locked', false)),
|
|
|
|
|
'ignored' => JsonValueGuard::nullableString(Arr::get($data, 'ignored')),
|
2020-04-04 10:59:25 -07:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
}
|