misc_pterodactyl-panel/app/Http/Controllers/Admin/ServersController.php

631 lines
22 KiB
PHP
Raw Normal View History

<?php
2016-01-20 00:10:39 +00:00
/**
2016-01-20 21:05:16 +00:00
* Pterodactyl - Panel
2017-01-24 22:57:08 +00:00
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
2016-01-20 00:10:39 +00:00
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
2016-01-20 00:10:39 +00:00
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
2016-01-20 00:10:39 +00:00
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
2016-01-20 00:10:39 +00:00
*/
2016-12-07 22:46:38 +00:00
namespace Pterodactyl\Http\Controllers\Admin;
use Javascript;
2016-12-07 22:46:38 +00:00
use Illuminate\Http\Request;
2017-08-05 22:26:30 +00:00
use Pterodactyl\Models\Server;
use Prologue\Alerts\AlertsMessageBag;
2016-12-07 22:46:38 +00:00
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Services\Servers\CreationService;
use Pterodactyl\Services\Servers\DeletionService;
use Pterodactyl\Services\Servers\ReinstallService;
use Pterodactyl\Services\Servers\SuspensionService;
2017-08-05 22:26:30 +00:00
use Pterodactyl\Http\Requests\Admin\ServerFormRequest;
use Pterodactyl\Services\Servers\ContainerRebuildService;
use Pterodactyl\Services\Servers\BuildModificationService;
use Pterodactyl\Services\Database\DatabaseManagementService;
use Pterodactyl\Services\Servers\DetailsModificationService;
use Pterodactyl\Services\Servers\StartupModificationService;
use Pterodactyl\Contracts\Repository\NodeRepositoryInterface;
use Pterodactyl\Repositories\Eloquent\DatabaseHostRepository;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
use Pterodactyl\Contracts\Repository\ServiceRepositoryInterface;
use Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface;
use Pterodactyl\Contracts\Repository\LocationRepositoryInterface;
use Pterodactyl\Contracts\Repository\AllocationRepositoryInterface;
class ServersController extends Controller
{
/**
* @var \Prologue\Alerts\AlertsMessageBag
*/
protected $alert;
/**
* @var \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface
*/
protected $allocationRepository;
/**
* @var \Pterodactyl\Services\Servers\BuildModificationService
*/
protected $buildModificationService;
2017-07-15 16:52:34 +00:00
/**
* @var \Illuminate\Contracts\Config\Repository
*/
protected $config;
/**
* @var \Pterodactyl\Services\Servers\ContainerRebuildService
*/
protected $containerRebuildService;
2017-07-15 16:52:34 +00:00
/**
* @var \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface
*/
protected $databaseRepository;
/**
* @var \Pterodactyl\Services\Database\DatabaseManagementService
*/
protected $databaseManagementService;
/**
* @var \Pterodactyl\Contracts\Repository\DatabaseHostRepositoryInterface
*/
protected $databaseHostRepository;
/**
* @var \Pterodactyl\Services\Servers\DeletionService
*/
protected $deletionService;
/**
* @var \Pterodactyl\Services\Servers\DetailsModificationService
*/
protected $detailsModificationService;
2017-07-15 16:52:34 +00:00
/**
* @var \Pterodactyl\Contracts\Repository\LocationRepositoryInterface
*/
protected $locationRepository;
/**
* @var \Pterodactyl\Contracts\Repository\NodeRepositoryInterface
*/
protected $nodeRepository;
/**
* @var \Pterodactyl\Services\Servers\ReinstallService
*/
protected $reinstallService;
2017-07-15 16:52:34 +00:00
/**
* @var \Pterodactyl\Contracts\Repository\ServerRepositoryInterface
*/
protected $repository;
/**
* @var \Pterodactyl\Services\Servers\CreationService
*/
protected $service;
2017-07-15 16:52:34 +00:00
/**
* @var \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface
*/
protected $serviceRepository;
/**
* @var \Pterodactyl\Services\Servers\StartupModificationService
*/
private $startupModificationService;
/**
* @var \Pterodactyl\Services\Servers\SuspensionService
*/
protected $suspensionService;
/**
* ServersController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Contracts\Repository\AllocationRepositoryInterface $allocationRepository
* @param \Pterodactyl\Services\Servers\BuildModificationService $buildModificationService
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Pterodactyl\Services\Servers\ContainerRebuildService $containerRebuildService
* @param \Pterodactyl\Services\Servers\CreationService $service
* @param \Pterodactyl\Services\Database\DatabaseManagementService $databaseManagementService
* @param \Pterodactyl\Contracts\Repository\DatabaseRepositoryInterface $databaseRepository
* @param \Pterodactyl\Repositories\Eloquent\DatabaseHostRepository $databaseHostRepository
* @param \Pterodactyl\Services\Servers\DeletionService $deletionService
* @param \Pterodactyl\Services\Servers\DetailsModificationService $detailsModificationService
* @param \Pterodactyl\Contracts\Repository\LocationRepositoryInterface $locationRepository
* @param \Pterodactyl\Contracts\Repository\NodeRepositoryInterface $nodeRepository
* @param \Pterodactyl\Services\Servers\ReinstallService $reinstallService
* @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $repository
* @param \Pterodactyl\Contracts\Repository\ServiceRepositoryInterface $serviceRepository
* @param \Pterodactyl\Services\Servers\StartupModificationService $startupModificationService
* @param \Pterodactyl\Services\Servers\SuspensionService $suspensionService
*/
2017-07-15 16:52:34 +00:00
public function __construct(
AlertsMessageBag $alert,
AllocationRepositoryInterface $allocationRepository,
BuildModificationService $buildModificationService,
2017-07-15 16:52:34 +00:00
ConfigRepository $config,
ContainerRebuildService $containerRebuildService,
CreationService $service,
DatabaseManagementService $databaseManagementService,
2017-07-15 16:52:34 +00:00
DatabaseRepositoryInterface $databaseRepository,
DatabaseHostRepository $databaseHostRepository,
DeletionService $deletionService,
DetailsModificationService $detailsModificationService,
2017-07-15 16:52:34 +00:00
LocationRepositoryInterface $locationRepository,
NodeRepositoryInterface $nodeRepository,
ReinstallService $reinstallService,
2017-07-15 16:52:34 +00:00
ServerRepositoryInterface $repository,
ServiceRepositoryInterface $serviceRepository,
StartupModificationService $startupModificationService,
SuspensionService $suspensionService
2017-07-15 16:52:34 +00:00
) {
$this->alert = $alert;
$this->allocationRepository = $allocationRepository;
$this->buildModificationService = $buildModificationService;
2017-07-15 16:52:34 +00:00
$this->config = $config;
$this->containerRebuildService = $containerRebuildService;
$this->databaseManagementService = $databaseManagementService;
2017-07-15 16:52:34 +00:00
$this->databaseRepository = $databaseRepository;
$this->databaseHostRepository = $databaseHostRepository;
$this->detailsModificationService = $detailsModificationService;
$this->deletionService = $deletionService;
2017-07-15 16:52:34 +00:00
$this->locationRepository = $locationRepository;
$this->nodeRepository = $nodeRepository;
$this->reinstallService = $reinstallService;
2017-07-15 16:52:34 +00:00
$this->repository = $repository;
$this->service = $service;
2017-07-15 16:52:34 +00:00
$this->serviceRepository = $serviceRepository;
$this->startupModificationService = $startupModificationService;
$this->suspensionService = $suspensionService;
2017-07-15 16:52:34 +00:00
}
/**
2017-03-05 00:03:49 +00:00
* Display the index page with all servers currently on the system.
*
* @return \Illuminate\View\View
*/
2017-07-15 16:52:34 +00:00
public function index()
{
return view('admin.servers.index', [
2017-07-15 16:52:34 +00:00
'servers' => $this->repository->getAllServers(
$this->config->get('pterodactyl.paginate.admin.servers')
),
]);
}
2017-03-05 00:03:49 +00:00
/**
* Display create new server page.
*
* @return \Illuminate\View\View
2017-07-15 16:52:34 +00:00
*
* @throws \Exception
2017-03-05 00:03:49 +00:00
*/
2017-07-15 16:52:34 +00:00
public function create()
{
2017-07-15 16:52:34 +00:00
$services = $this->serviceRepository->getWithOptions();
Javascript::put([
'services' => $services->map(function ($item) {
return array_merge($item->toArray(), [
'options' => $item->options->keyBy('id')->toArray(),
]);
})->keyBy('id'),
]);
return view('admin.servers.new', [
2017-07-15 16:52:34 +00:00
'locations' => $this->locationRepository->all(),
'services' => $services,
]);
}
2017-03-05 00:03:49 +00:00
/**
* Handle POST of server creation form.
2017-03-05 00:03:49 +00:00
*
* @param \Pterodactyl\Http\Requests\Admin\ServerFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
2017-03-05 00:03:49 +00:00
*/
public function store(ServerFormRequest $request)
2015-12-10 23:30:47 +00:00
{
$server = $this->service->create($request->except('_token'));
$this->alert->success(trans('admin/server.alerts.server_created'))->flash();
2017-03-05 00:03:49 +00:00
return redirect()->route('admin.servers.view', $server->id);
2015-12-10 23:30:47 +00:00
}
/**
2017-03-05 00:03:49 +00:00
* Returns a tree of all avaliable nodes in a given location.
2015-12-10 23:30:47 +00:00
*
2017-07-22 19:07:51 +00:00
* @param \Illuminate\Http\Request $request
2017-07-15 16:52:34 +00:00
* @return \Illuminate\Support\Collection
2015-12-10 23:30:47 +00:00
*/
2017-04-09 23:13:22 +00:00
public function nodes(Request $request)
2015-12-10 23:30:47 +00:00
{
return $this->nodeRepository->getNodesForLocation($request->input('location'));
2015-12-10 23:30:47 +00:00
}
2017-03-05 00:03:49 +00:00
/**
* Display the index when viewing a specific server.
*
2017-07-23 20:09:25 +00:00
* @param \Pterodactyl\Models\Server $server
2017-03-05 00:03:49 +00:00
* @return \Illuminate\View\View
*/
2017-07-23 20:09:25 +00:00
public function viewIndex(Server $server)
2017-03-05 00:03:49 +00:00
{
2017-07-23 20:09:25 +00:00
return view('admin.servers.view.index', ['server' => $server]);
2017-03-05 00:03:49 +00:00
}
/**
* Display the details page when viewing a specific server.
*
2017-07-23 20:09:25 +00:00
* @param int $server
2017-03-05 00:03:49 +00:00
* @return \Illuminate\View\View
*/
2017-07-23 20:09:25 +00:00
public function viewDetails($server)
2017-03-05 00:03:49 +00:00
{
return view('admin.servers.view.details', [
'server' => $this->repository->findFirstWhere([
2017-07-23 20:09:25 +00:00
['id', '=', $server],
['installed', '=', 1],
]),
]);
2017-03-05 00:03:49 +00:00
}
/**
* Display the build details page when viewing a specific server.
*
2017-07-23 20:09:25 +00:00
* @param int $server
2017-03-05 00:03:49 +00:00
* @return \Illuminate\View\View
*/
2017-07-23 20:09:25 +00:00
public function viewBuild($server)
{
$server = $this->repository->findFirstWhere([
2017-07-23 20:09:25 +00:00
['id', '=', $server],
['installed', '=', 1],
]);
$allocations = $this->allocationRepository->getAllocationsForNode($server->node_id);
2017-03-05 00:03:49 +00:00
return view('admin.servers.view.build', [
'server' => $server,
'assigned' => $allocations->where('server_id', $server->id)->sortBy('port')->sortBy('ip'),
'unassigned' => $allocations->where('server_id', null)->sortBy('port')->sortBy('ip'),
2017-03-05 00:03:49 +00:00
]);
}
/**
* Display startup configuration page for a server.
*
2017-07-23 20:09:25 +00:00
* @param int $server
2017-03-05 00:03:49 +00:00
* @return \Illuminate\View\View
*/
2017-07-23 20:09:25 +00:00
public function viewStartup($server)
2017-03-05 00:03:49 +00:00
{
2017-07-23 20:09:25 +00:00
$parameters = $this->repository->getVariablesWithValues($server, true);
if (! $parameters->server->installed) {
abort(404);
}
2017-03-05 00:03:49 +00:00
$services = $this->serviceRepository->getWithOptions();
2017-03-05 00:03:49 +00:00
Javascript::put([
'services' => $services->map(function ($item) {
return array_merge($item->toArray(), [
'options' => $item->options->keyBy('id')->toArray(),
]);
})->keyBy('id'),
'server_variables' => $parameters->data,
]);
return view('admin.servers.view.startup', [
'server' => $parameters->server,
'services' => $services,
]);
2017-03-05 00:03:49 +00:00
}
/**
* Display the database management page for a specific server.
*
2017-07-23 20:09:25 +00:00
* @param int $server
2017-03-05 00:03:49 +00:00
* @return \Illuminate\View\View
*/
2017-07-23 20:09:25 +00:00
public function viewDatabase($server)
2017-03-05 00:03:49 +00:00
{
2017-07-23 20:09:25 +00:00
$server = $this->repository->getWithDatabases($server);
2017-03-05 00:03:49 +00:00
return view('admin.servers.view.database', [
'hosts' => $this->databaseHostRepository->all(),
2017-03-06 01:28:29 +00:00
'server' => $server,
]);
2017-03-05 00:03:49 +00:00
}
/**
* Display the management page when viewing a specific server.
*
2017-07-23 20:09:25 +00:00
* @param \Pterodactyl\Models\Server $server
2017-03-05 00:03:49 +00:00
* @return \Illuminate\View\View
*/
2017-07-23 20:09:25 +00:00
public function viewManage(Server $server)
2017-03-05 00:03:49 +00:00
{
2017-07-23 20:09:25 +00:00
return view('admin.servers.view.manage', ['server' => $server]);
2017-03-05 00:03:49 +00:00
}
/**
* Display the deletion page for a server.
*
2017-07-23 20:09:25 +00:00
* @param \Pterodactyl\Models\Server $server
2017-03-05 00:03:49 +00:00
* @return \Illuminate\View\View
*/
2017-07-23 20:09:25 +00:00
public function viewDelete(Server $server)
2017-03-05 00:03:49 +00:00
{
2017-07-23 20:09:25 +00:00
return view('admin.servers.view.delete', ['server' => $server]);
2017-03-05 00:03:49 +00:00
}
/**
* Update the details for a server.
*
2017-07-23 20:09:25 +00:00
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Server $server
2017-03-19 23:36:50 +00:00
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
2017-03-05 00:03:49 +00:00
*/
public function setDetails(Request $request, Server $server)
2017-03-05 00:03:49 +00:00
{
$this->detailsModificationService->edit($server, $request->only([
'owner_id', 'name', 'description', 'reset_token',
]));
$this->alert->success(trans('admin/server.alerts.details_updated'))->flash();
return redirect()->route('admin.servers.view.details', $server->id);
}
2017-03-05 00:03:49 +00:00
/**
* Set the new docker container for a server.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Server $server
2017-03-19 23:36:50 +00:00
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
2017-03-05 00:03:49 +00:00
*/
public function setContainer(Request $request, Server $server)
2016-12-07 22:46:38 +00:00
{
$this->detailsModificationService->setDockerImage($server, $request->input('docker_image'));
$this->alert->success(trans('admin/server.alerts.docker_image_updated'))->flash();
return redirect()->route('admin.servers.view.details', $server->id);
2017-03-05 00:03:49 +00:00
}
/**
* Toggles the install status for a server.
*
* @param \Pterodactyl\Models\Server $server
2017-03-19 23:36:50 +00:00
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
2017-03-05 00:03:49 +00:00
*/
public function toggleInstall(Server $server)
2017-03-05 00:03:49 +00:00
{
if ($server->installed > 1) {
throw new DisplayException(trans('admin/server.exceptions.marked_as_failed'));
2017-03-05 00:03:49 +00:00
}
$this->repository->update($server->id, [
'installed' => ! $server->installed,
]);
$this->alert->success(trans('admin/server.alerts.install_toggled'))->flash();
return redirect()->route('admin.servers.view.manage', $server->id);
}
/**
* Reinstalls the server with the currently assigned pack and service.
*
2017-07-23 20:09:25 +00:00
* @param \Pterodactyl\Models\Server $server
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
2017-07-23 20:09:25 +00:00
public function reinstallServer(Server $server)
{
2017-07-23 20:09:25 +00:00
$this->reinstallService->reinstall($server);
$this->alert->success(trans('admin/server.alerts.server_reinstalled'))->flash();
2017-07-23 20:09:25 +00:00
return redirect()->route('admin.servers.view.manage', $server->id);
}
2017-03-05 00:03:49 +00:00
/**
* Setup a server to have a container rebuild.
*
* @param \Pterodactyl\Models\Server $server
2017-03-19 23:36:50 +00:00
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
2017-03-05 00:03:49 +00:00
*/
public function rebuildContainer(Server $server)
2016-12-07 22:46:38 +00:00
{
$this->containerRebuildService->rebuild($server);
$this->alert->success(trans('admin/server.alerts.rebuild_on_boot'))->flash();
return redirect()->route('admin.servers.view.manage', $server->id);
}
2017-03-05 00:03:49 +00:00
/**
* Manage the suspension status for a server.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Server $server
2017-03-19 23:36:50 +00:00
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
2017-03-05 00:03:49 +00:00
*/
public function manageSuspension(Request $request, Server $server)
{
$this->suspensionService->toggle($server, $request->input('action'));
$this->alert->success(trans('admin/server.alerts.suspension_toggled', [
'status' => $request->input('action') . 'ed',
]))->flash();
2017-03-05 00:03:49 +00:00
return redirect()->route('admin.servers.view.manage', $server->id);
}
2017-03-05 00:03:49 +00:00
/**
* Update the build configuration for a server.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Server $server
2017-03-19 23:36:50 +00:00
* @return \Illuminate\Http\RedirectResponse
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @internal param int $id
2017-03-05 00:03:49 +00:00
*/
public function updateBuild(Request $request, Server $server)
{
$this->buildModificationService->handle($server, $request->only([
'allocation_id', 'add_allocations', 'remove_allocations',
'memory', 'swap', 'io', 'cpu', 'disk',
]));
$this->alert->success(trans('admin/server.alerts.build_updated'))->flash();
2016-12-07 22:46:38 +00:00
return redirect()->route('admin.servers.view.build', $server->id);
}
2017-03-05 00:03:49 +00:00
/**
* Start the server deletion process.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Server $server
2017-03-19 23:36:50 +00:00
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
2017-03-05 00:03:49 +00:00
*/
public function delete(Request $request, Server $server)
2016-01-04 21:09:22 +00:00
{
$this->deletionService->withForce($request->has('force_delete'))->handle($server);
$this->alert->success(trans('admin/server.alerts.server_deleted'))->flash();
2017-03-05 00:03:49 +00:00
return redirect()->route('admin.servers');
}
2017-03-05 00:03:49 +00:00
/**
* Update the startup command as well as variables.
*
* @param \Illuminate\Http\Request $request
* @param \Pterodactyl\Models\Server $server
2017-03-19 23:36:50 +00:00
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function saveStartup(Request $request, Server $server)
{
$this->startupModificationService->isAdmin()->handle(
$server, $request->except('_token')
);
$this->alert->success(trans('admin/server.alerts.startup_changed'))->flash();
return redirect()->route('admin.servers.view.startup', $server->id);
}
/**
* Creates a new database assigned to a specific server.
2017-03-19 23:36:50 +00:00
*
2017-07-22 19:07:51 +00:00
* @param \Illuminate\Http\Request $request
2017-07-23 20:09:25 +00:00
* @param int $server
2017-03-19 23:36:50 +00:00
* @return \Illuminate\Http\RedirectResponse
2017-07-22 19:07:51 +00:00
*
* @throws \Exception
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
2017-07-23 20:09:25 +00:00
public function newDatabase(Request $request, $server)
{
$this->databaseManagementService->create($server, [
'database' => $request->input('database'),
'remote' => $request->input('remote'),
'database_host_id' => $request->input('database_host_id'),
]);
2017-07-23 20:09:25 +00:00
return redirect()->route('admin.servers.view.database', $server)->withInput();
}
/**
* Resets the database password for a specific database on this server.
2017-03-19 23:36:50 +00:00
*
2017-07-22 19:07:51 +00:00
* @param \Illuminate\Http\Request $request
2017-07-23 20:09:25 +00:00
* @param int $server
2017-03-19 23:36:50 +00:00
* @return \Illuminate\Http\RedirectResponse
2017-07-22 19:07:51 +00:00
*
* @throws \Exception
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
2017-07-23 20:09:25 +00:00
public function resetDatabasePassword(Request $request, $server)
{
2017-07-22 19:07:51 +00:00
$database = $this->databaseRepository->findFirstWhere([
2017-07-23 20:09:25 +00:00
['server_id', '=', $server],
2017-07-22 19:07:51 +00:00
['id', '=', $request->input('database')],
]);
$this->databaseManagementService->changePassword($database->id, str_random(20));
2017-07-22 19:07:51 +00:00
return response('', 204);
}
/**
* Deletes a database from a server.
2017-03-19 23:36:50 +00:00
*
2017-07-23 20:09:25 +00:00
* @param int $server
* @param int $database
2017-03-19 23:36:50 +00:00
* @return \Illuminate\Http\RedirectResponse
2017-07-22 19:07:51 +00:00
*
* @throws \Exception
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
2017-07-23 20:09:25 +00:00
public function deleteDatabase($server, $database)
{
2017-07-22 19:07:51 +00:00
$database = $this->databaseRepository->findFirstWhere([
2017-07-23 20:09:25 +00:00
['server_id', '=', $server],
2017-07-22 19:07:51 +00:00
['id', '=', $database],
]);
$this->databaseManagementService->delete($database->id);
2017-07-22 19:07:51 +00:00
return response('', 204);
}
}