initiateBackupService = $initiateBackupService; $this->deleteBackupService = $deleteBackupService; } /** * Returns all of the backups for a given server instance in a paginated * result set. * * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\GetBackupsRequest $request * @param \Pterodactyl\Models\Server $server * @return array */ public function index(GetBackupsRequest $request, Server $server) { return $this->fractal->collection($server->backups()->paginate(20)) ->transformWith($this->getTransformer(BackupTransformer::class)) ->toArray(); } /** * Starts the backup process for a server. * * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\StoreBackupRequest $request * @param \Pterodactyl\Models\Server $server * @return array * * @throws \Exception|\Throwable */ public function store(StoreBackupRequest $request, Server $server) { $backup = $this->initiateBackupService ->setIgnoredFiles($request->input('ignored')) ->handle($server, $request->input('name')); return $this->fractal->item($backup) ->transformWith($this->getTransformer(BackupTransformer::class)) ->toArray(); } /** * Returns information about a single backup. * * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\GetBackupsRequest $request * @param \Pterodactyl\Models\Server $server * @param \Pterodactyl\Models\Backup $backup * @return array */ public function view(GetBackupsRequest $request, Server $server, Backup $backup) { return $this->fractal->item($backup) ->transformWith($this->getTransformer(BackupTransformer::class)) ->toArray(); } /** * Deletes a backup from the panel as well as the remote source where it is currently * being stored. * * @param \Pterodactyl\Http\Requests\Api\Client\Servers\Backups\DeleteBackupRequest $request * @param \Pterodactyl\Models\Server $server * @param \Pterodactyl\Models\Backup $backup * @return \Illuminate\Http\JsonResponse * * @throws \Throwable */ public function delete(DeleteBackupRequest $request, Server $server, Backup $backup) { $this->deleteBackupService->handle($backup); return JsonResponse::create([], JsonResponse::HTTP_NO_CONTENT); } }