Nest & Egg management working through the ACP now.

This commit is contained in:
Dane Everitt 2017-10-07 16:16:51 -05:00
parent df87ea0867
commit 6b8464ea3a
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
32 changed files with 616 additions and 566 deletions

View file

@ -7,7 +7,7 @@
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Exceptions\Service\ServiceOption;
namespace Pterodactyl\Exceptions\Service\Egg;
use Pterodactyl\Exceptions\DisplayException;

View file

@ -7,10 +7,10 @@
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Exceptions\Service\ServiceVariable;
namespace Pterodactyl\Exceptions\Service\Egg;
use Exception;
use Pterodactyl\Exceptions\DisplayException;
class ReservedVariableNameException extends Exception
class InvalidCopyFromException extends DisplayException
{
}

View file

@ -7,8 +7,10 @@
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Exceptions\Service\ServiceOption;
namespace Pterodactyl\Exceptions\Service\Egg;
class NoParentConfigurationFoundException extends \Exception
use Pterodactyl\Exceptions\DisplayException;
class NoParentConfigurationFoundException extends DisplayException
{
}

View file

@ -7,8 +7,10 @@
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Exceptions\Service\ServiceOption;
namespace Pterodactyl\Exceptions\Service\Egg\Variable;
class InvalidCopyFromException extends \Exception
use Pterodactyl\Exceptions\DisplayException;
class ReservedVariableNameException extends DisplayException
{
}

View file

@ -12,12 +12,12 @@ namespace Pterodactyl\Http\Controllers\API\Remote;
use Illuminate\Http\JsonResponse;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
use Pterodactyl\Services\Services\Options\OptionConfigurationFileService;
use Pterodactyl\Services\Services\Options\EggConfigurationService;
class OptionRetrievalController extends Controller
{
/**
* @var \Pterodactyl\Services\Services\Options\OptionConfigurationFileService
* @var \Pterodactyl\Services\Services\Options\EggConfigurationService
*/
protected $configurationFileService;
@ -29,12 +29,12 @@ class OptionRetrievalController extends Controller
/**
* OptionUpdateController constructor.
*
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
* @param \Pterodactyl\Services\Services\Options\OptionConfigurationFileService $configurationFileService
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
* @param \Pterodactyl\Services\Services\Options\EggConfigurationService $configurationFileService
*/
public function __construct(
EggRepositoryInterface $repository,
OptionConfigurationFileService $configurationFileService
EggConfigurationService $configurationFileService
) {
$this->configurationFileService = $configurationFileService;
$this->repository = $repository;

View file

@ -9,24 +9,120 @@
namespace Pterodactyl\Http\Controllers\Admin\Nests;
use Javascript;
use Illuminate\View\View;
use Pterodactyl\Models\Egg;
use Illuminate\Http\RedirectResponse;
use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Services\Eggs\EggUpdateService;
use Pterodactyl\Services\Eggs\EggCreationService;
use Pterodactyl\Services\Eggs\EggDeletionService;
use Pterodactyl\Http\Requests\Admin\Egg\EggFormRequest;
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
class EggController extends Controller
{
protected $alert;
protected $creationService;
protected $deletionService;
protected $nestRepository;
protected $repository;
protected $updateService;
public function __construct(EggRepositoryInterface $repository)
{
public function __construct(
AlertsMessageBag $alert,
EggCreationService $creationService,
EggDeletionService $deletionService,
EggRepositoryInterface $repository,
EggUpdateService $updateService,
NestRepositoryInterface $nestRepository
) {
$this->alert = $alert;
$this->creationService = $creationService;
$this->deletionService = $deletionService;
$this->nestRepository = $nestRepository;
$this->repository = $repository;
$this->updateService = $updateService;
}
/**
* Handle a request to display the Egg creation page.
*
* @return \Illuminate\View\View
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function create(): View
{
$nests = $this->nestRepository->getWithEggs();
Javascript::put(['nests' => $nests->keyBy('id')]);
return view('admin.eggs.new', ['nests' => $nests]);
}
/**
* Handle request to store a new Egg.
*
* @param \Pterodactyl\Http\Requests\Admin\Egg\EggFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException
*/
public function store(EggFormRequest $request): RedirectResponse
{
$egg = $this->creationService->handle($request->normalize());
$this->alert->success(trans('admin/nests.eggs.notices.egg_created'))->flash();
return redirect()->route('admin.nests.egg.view', $egg->id);
}
/**
* Handle request to view a single Egg.
*
* @param \Pterodactyl\Models\Egg $egg
* @return \Illuminate\View\View
*/
public function view(Egg $egg): View
{
return view('admin.eggs.view', [
'egg' => $egg,
]);
return view('admin.eggs.view', ['egg' => $egg]);
}
/**
* Handle request to update an Egg.
*
* @param \Pterodactyl\Http\Requests\Admin\Egg\EggFormRequest $request
* @param \Pterodactyl\Models\Egg $egg
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException
*/
public function update(EggFormRequest $request, Egg $egg): RedirectResponse
{
$this->updateService->handle($egg, $request->normalize());
$this->alert->success(trans('admin/nests.eggs.notices.updated'))->flash();
return redirect()->route('admin.nests.egg.view', $egg->id);
}
/**
* Handle request to destroy an egg.
*
* @param \Pterodactyl\Models\Egg $egg
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Service\Egg\HasChildrenException
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
*/
public function destroy(Egg $egg): RedirectResponse
{
$this->deletionService->handle($egg->id);
$this->alert->success(trans('admin/nests.eggs.notices.deleted'))->flash();
return redirect()->route('admin.nests.view', $egg->nest_id);
}
}

View file

@ -0,0 +1,98 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Http\Controllers\Admin\Nests;
use Illuminate\View\View;
use Illuminate\Http\RedirectResponse;
use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Services\Eggs\Scripts\InstallScriptService;
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
use Pterodactyl\Http\Requests\Admin\Egg\EggScriptFormRequest;
class EggScriptController extends Controller
{
/**
* @var \Prologue\Alerts\AlertsMessageBag
*/
protected $alert;
/**
* @var \Pterodactyl\Services\Eggs\Scripts\InstallScriptService
*/
protected $installScriptService;
/**
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
*/
protected $repository;
/**
* EggScriptController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
* @param \Pterodactyl\Services\Eggs\Scripts\InstallScriptService $installScriptService
*/
public function __construct(
AlertsMessageBag $alert,
EggRepositoryInterface $repository,
InstallScriptService $installScriptService
) {
$this->alert = $alert;
$this->installScriptService = $installScriptService;
$this->repository = $repository;
}
/**
* Handle requests to render installation script for an Egg.
*
* @param int $egg
* @return \Illuminate\View\View
*/
public function index(int $egg): View
{
$egg = $this->repository->getWithCopyAttributes($egg);
$copy = $this->repository->findWhere([
['copy_script_from', '=', null],
['nest_id', '=', $egg->nest_id],
['id', '!=', $egg],
]);
$rely = $this->repository->findWhere([
['copy_script_from', '=', $egg->id],
]);
return view('admin.eggs.scripts', [
'copyFromOptions' => $copy,
'relyOnScript' => $rely,
'egg' => $egg,
]);
}
/**
* Handle a request to update the installation script for an Egg.
*
* @param \Pterodactyl\Http\Requests\Admin\Egg\EggScriptFormRequest $request
* @param int $egg
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Pterodactyl\Exceptions\Service\Egg\InvalidCopyFromException
*/
public function update(EggScriptFormRequest $request, int $egg): RedirectResponse
{
$this->installScriptService->handle($egg, $request->normalize());
$this->alert->success(trans('admin/nests.eggs.notices.script_updated'))->flash();
return redirect()->route('admin.nests.egg.scripts', $egg);
}
}

View file

@ -0,0 +1,146 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Http\Controllers\Admin\Nests;
use Illuminate\View\View;
use Pterodactyl\Models\Egg;
use Pterodactyl\Models\EggVariable;
use Illuminate\Http\RedirectResponse;
use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
use Pterodactyl\Services\Eggs\Variables\VariableUpdateService;
use Pterodactyl\Http\Requests\Admin\Egg\EggVariableFormRequest;
use Pterodactyl\Services\Eggs\Variables\VariableCreationService;
use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface;
class EggVariableController extends Controller
{
/**
* @var \Prologue\Alerts\AlertsMessageBag
*/
protected $alert;
/**
* @var \Pterodactyl\Services\Eggs\Variables\VariableCreationService
*/
protected $creationService;
/**
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
*/
protected $repository;
/**
* @var \Pterodactyl\Services\Eggs\Variables\VariableUpdateService
*/
protected $updateService;
/**
* @var \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface
*/
protected $variableRepository;
/**
* EggVariableController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Services\Eggs\Variables\VariableCreationService $creationService
* @param \Pterodactyl\Services\Eggs\Variables\VariableUpdateService $updateService
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
* @param \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface $variableRepository
*/
public function __construct(
AlertsMessageBag $alert,
VariableCreationService $creationService,
VariableUpdateService $updateService,
EggRepositoryInterface $repository,
EggVariableRepositoryInterface $variableRepository
) {
$this->alert = $alert;
$this->creationService = $creationService;
$this->repository = $repository;
$this->updateService = $updateService;
$this->variableRepository = $variableRepository;
}
/**
* Handle request to view the variables attached to an Egg.
*
* @param int $egg
* @return \Illuminate\View\View
*
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function view(int $egg): View
{
$egg = $this->repository->getWithVariables($egg);
return view('admin.eggs.variables', ['egg' => $egg]);
}
/**
* Handle a request to create a new Egg variable.
*
* @param \Pterodactyl\Http\Requests\Admin\Egg\EggVariableFormRequest $request
* @param \Pterodactyl\Models\Egg $egg
*
* @return \Illuminate\Http\RedirectResponse
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException
*/
public function store(EggVariableFormRequest $request, Egg $egg): RedirectResponse
{
$this->creationService->handle($egg->id, $request->normalize());
$this->alert->success(trans('admin/nests.variables.notices.variable_created'))->flash();
return redirect()->route('admin.nests.egg.variables', $egg->id);
}
/**
* Handle a request to update an existing Egg variable.
*
* @param \Pterodactyl\Http\Requests\Admin\Egg\EggVariableFormRequest $request
* @param \Pterodactyl\Models\Egg $egg
* @param \Pterodactyl\Models\EggVariable $variable
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException
*/
public function update(EggVariableFormRequest $request, Egg $egg, EggVariable $variable): RedirectResponse
{
$this->updateService->handle($variable, $request->normalize());
$this->alert->success(trans('admin/nests.variables.notices.variable_updated', [
'variable' => $variable->name,
]))->flash();
return redirect()->route('admin.nests.egg.variables', $egg->id);
}
/**
* Handle a request to delete an existing Egg variable from the Panel.
*
* @param int $egg
* @param \Pterodactyl\Models\EggVariable $variable
* @return \Illuminate\Http\RedirectResponse
*/
public function destroy(int $egg, EggVariable $variable): RedirectResponse
{
$this->variableRepository->delete($variable->id);
$this->alert->success(trans('admin/nests.variables.notices.variable_deleted', [
'variable' => $variable->name,
]))->flash();
return redirect()->route('admin.nests.egg.variables', $egg);
}
}

View file

@ -145,12 +145,12 @@ class NestController extends Controller
/**
* Handle request to delete a nest.
*
* @param \Pterodactyl\Models\Nest $nest
* @param int $nest
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
*/
public function destroy($nest): RedirectResponse
public function destroy(int $nest): RedirectResponse
{
$this->nestDeletionService->handle($nest);
$this->alert->success(trans('admin/nests.notices.deleted'))->flash();

View file

@ -14,16 +14,16 @@ use Pterodactyl\Models\Egg;
use Illuminate\Http\Request;
use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Http\Requests\Admin\Service\EggFormRequest;
use Pterodactyl\Services\Services\Options\EggUpdateService;
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
use Pterodactyl\Http\Requests\Admin\Service\EditOptionScript;
use Pterodactyl\Services\Services\Options\OptionUpdateService;
use Pterodactyl\Services\Services\Options\OptionCreationService;
use Pterodactyl\Services\Services\Options\OptionDeletionService;
use Pterodactyl\Http\Requests\Admin\Service\ServiceOptionFormRequest;
use Pterodactyl\Services\Services\Options\InstallScriptUpdateService;
use Pterodactyl\Exceptions\Service\ServiceOption\InvalidCopyFromException;
use Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException;
use Pterodactyl\Services\Services\Options\EggCreationService;
use Pterodactyl\Services\Services\Options\EggDeletionService;
use Pterodactyl\Services\Services\Options\InstallScriptService;
use Pterodactyl\Exceptions\Service\Egg\InvalidCopyFromException;
use Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException;
class OptionController extends Controller
{
@ -33,22 +33,22 @@ class OptionController extends Controller
protected $alert;
/**
* @var \Pterodactyl\Services\Services\Options\InstallScriptUpdateService
* @var \Pterodactyl\Services\Services\Options\InstallScriptService
*/
protected $installScriptUpdateService;
/**
* @var \Pterodactyl\Services\Services\Options\OptionCreationService
* @var \Pterodactyl\Services\Services\Options\EggCreationService
*/
protected $optionCreationService;
/**
* @var \Pterodactyl\Services\Services\Options\OptionDeletionService
* @var \Pterodactyl\Services\Services\Options\EggDeletionService
*/
protected $optionDeletionService;
/**
* @var \Pterodactyl\Services\Services\Options\OptionUpdateService
* @var \Pterodactyl\Services\Services\Options\EggUpdateService
*/
protected $optionUpdateService;
@ -65,20 +65,20 @@ class OptionController extends Controller
/**
* OptionController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Services\Services\Options\InstallScriptUpdateService $installScriptUpdateService
* @param \Pterodactyl\Services\Services\Options\OptionCreationService $optionCreationService
* @param \Pterodactyl\Services\Services\Options\OptionDeletionService $optionDeletionService
* @param \Pterodactyl\Services\Services\Options\OptionUpdateService $optionUpdateService
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $serviceRepository
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $serviceOptionRepository
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Services\Services\Options\InstallScriptService $installScriptUpdateService
* @param \Pterodactyl\Services\Services\Options\EggCreationService $optionCreationService
* @param \Pterodactyl\Services\Services\Options\EggDeletionService $optionDeletionService
* @param \Pterodactyl\Services\Services\Options\EggUpdateService $optionUpdateService
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $serviceRepository
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $serviceOptionRepository
*/
public function __construct(
AlertsMessageBag $alert,
InstallScriptUpdateService $installScriptUpdateService,
OptionCreationService $optionCreationService,
OptionDeletionService $optionDeletionService,
OptionUpdateService $optionUpdateService,
InstallScriptService $installScriptUpdateService,
EggCreationService $optionCreationService,
EggDeletionService $optionDeletionService,
EggUpdateService $optionUpdateService,
NestRepositoryInterface $serviceRepository,
EggRepositoryInterface $serviceOptionRepository
) {
@ -107,12 +107,12 @@ class OptionController extends Controller
/**
* Handle adding a new service option.
*
* @param \Pterodactyl\Http\Requests\Admin\Service\ServiceOptionFormRequest $request
* @param \Pterodactyl\Http\Requests\Admin\Service\EggFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function store(ServiceOptionFormRequest $request)
public function store(EggFormRequest $request)
{
try {
$option = $this->optionCreationService->handle($request->normalize());

View file

@ -1,187 +0,0 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Http\Controllers\Admin;
use Illuminate\View\View;
use Pterodactyl\Models\Nest;
use Illuminate\Http\RedirectResponse;
use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Services\Services\NestUpdateService;
use Pterodactyl\Services\Services\NestCreationService;
use Pterodactyl\Services\Services\NestDeletionService;
use Pterodactyl\Contracts\Repository\NestRepositoryInterface;
use Pterodactyl\Http\Requests\Admin\Service\StoreNestFormRequest;
use Pterodactyl\Http\Requests\Admin\Service\ServiceFunctionsFormRequest;
class ServiceController extends Controller
{
/**
* @var \Prologue\Alerts\AlertsMessageBag
*/
protected $alert;
/**
* @var \Pterodactyl\Services\Services\NestCreationService
*/
protected $creationService;
/**
* @var \Pterodactyl\Services\Services\NestDeletionService
*/
protected $deletionService;
/**
* @var \Pterodactyl\Contracts\Repository\NestRepositoryInterface
*/
protected $repository;
/**
* @var \Pterodactyl\Services\Services\NestUpdateService
*/
protected $updateService;
/**
* ServiceController constructor.
*
* @param \Prologue\Alerts\AlertsMessageBag $alert
* @param \Pterodactyl\Services\Services\NestCreationService $creationService
* @param \Pterodactyl\Services\Services\NestDeletionService $deletionService
* @param \Pterodactyl\Contracts\Repository\NestRepositoryInterface $repository
* @param \Pterodactyl\Services\Services\NestUpdateService $updateService
*/
public function __construct(
AlertsMessageBag $alert,
NestCreationService $creationService,
NestDeletionService $deletionService,
NestRepositoryInterface $repository,
NestUpdateService $updateService
) {
$this->alert = $alert;
$this->creationService = $creationService;
$this->deletionService = $deletionService;
$this->repository = $repository;
$this->updateService = $updateService;
}
/**
* Display service overview page.
*
* @return \Illuminate\View\View
*/
public function index(): View
{
return view('admin.services.index', [
'services' => $this->repository->getWithCounts(),
]);
}
/**
* Display create service page.
*
* @return \Illuminate\View\View
*/
public function create(): View
{
return view('admin.services.new');
}
/**
* Return base view for a service.
*
* @param int $service
* @return \Illuminate\View\View
*/
public function view(int $service): View
{
return view('admin.services.view', [
'service' => $this->repository->getWithOptionServers($service),
]);
}
/**
* Return function editing view for a service.
*
* @param \Pterodactyl\Models\Nest $service
* @return \Illuminate\View\View
*/
public function viewFunctions(Nest $service): View
{
return view('admin.services.functions', ['service' => $service]);
}
/**
* Handle post action for new service.
*
* @param \Pterodactyl\Http\Requests\Admin\Service\StoreNestFormRequest $request
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
*/
public function store(StoreNestFormRequest $request): RedirectResponse
{
$service = $this->creationService->handle($request->normalize());
$this->alert->success(trans('admin/services.notices.service_created', ['name' => $service->name]))->flash();
return redirect()->route('admin.services.view', $service->id);
}
/**
* Edits configuration for a specific service.
*
* @param \Pterodactyl\Http\Requests\Admin\Service\StoreNestFormRequest $request
* @param \Pterodactyl\Models\Nest $service
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function update(StoreNestFormRequest $request, Nest $service): RedirectResponse
{
$this->updateService->handle($service->id, $request->normalize());
$this->alert->success(trans('admin/services.notices.service_updated'))->flash();
return redirect()->route('admin.services.view', $service);
}
/**
* Update the functions file for a service.
*
* @param \Pterodactyl\Http\Requests\Admin\Service\ServiceFunctionsFormRequest $request
* @param \Pterodactyl\Models\Nest $service
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function updateFunctions(ServiceFunctionsFormRequest $request, Nest $service): RedirectResponse
{
$this->updateService->handle($service->id, $request->normalize());
$this->alert->success(trans('admin/services.notices.functions_updated'))->flash();
return redirect()->route('admin.services.view.functions', $service->id);
}
/**
* Delete a service from the panel.
*
* @param \Pterodactyl\Models\Nest $service
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
*/
public function destroy(Nest $service): RedirectResponse
{
$this->deletionService->handle($service->id);
$this->alert->success(trans('admin/services.notices.service_deleted'))->flash();
return redirect()->route('admin.services');
}
}

View file

@ -1,133 +0,0 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Http\Controllers\Admin;
use Pterodactyl\Models\Egg;
use Pterodactyl\Models\EggVariable;
use Prologue\Alerts\AlertsMessageBag;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
use Pterodactyl\Http\Requests\Admin\OptionVariableFormRequest;
use Pterodactyl\Repositories\Eloquent\ServiceVariableRepository;
use Pterodactyl\Services\Services\Variables\VariableUpdateService;
use Pterodactyl\Services\Services\Variables\VariableCreationService;
class VariableController extends Controller
{
/**
* @var \Prologue\Alerts\AlertsMessageBag
*/
protected $alert;
/**
* @var \Pterodactyl\Services\Services\Variables\VariableCreationService
*/
protected $creationService;
/**
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
*/
protected $serviceOptionRepository;
/**
* @var \Pterodactyl\Repositories\Eloquent\ServiceVariableRepository
*/
protected $serviceVariableRepository;
/**
* @var \Pterodactyl\Services\Services\Variables\VariableUpdateService
*/
protected $updateService;
public function __construct(
AlertsMessageBag $alert,
EggRepositoryInterface $serviceOptionRepository,
ServiceVariableRepository $serviceVariableRepository,
VariableCreationService $creationService,
VariableUpdateService $updateService
) {
$this->alert = $alert;
$this->creationService = $creationService;
$this->serviceOptionRepository = $serviceOptionRepository;
$this->serviceVariableRepository = $serviceVariableRepository;
$this->updateService = $updateService;
}
/**
* Handles POST request to create a new option variable.
*
* @param \Pterodactyl\Http\Requests\Admin\OptionVariableFormRequest $request
* @param \Pterodactyl\Models\Egg $option
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Service\ServiceVariable\ReservedVariableNameException
*/
public function store(OptionVariableFormRequest $request, Egg $option)
{
$this->creationService->handle($option->id, $request->normalize());
$this->alert->success(trans('admin/services.variables.notices.variable_created'))->flash();
return redirect()->route('admin.services.option.variables', $option->id);
}
/**
* Display variable overview page for a service option.
*
* @param int $option
* @return \Illuminate\View\View
*/
public function view($option)
{
$option = $this->serviceOptionRepository->getWithVariables($option);
return view('admin.services.options.variables', ['option' => $option]);
}
/**
* Handles POST when editing a configration for a service variable.
*
* @param \Pterodactyl\Http\Requests\Admin\OptionVariableFormRequest $request
* @param \Pterodactyl\Models\Egg $option
* @param \Pterodactyl\Models\EggVariable $variable
* @return \Illuminate\Http\RedirectResponse
*
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Pterodactyl\Exceptions\Service\ServiceVariable\ReservedVariableNameException
*/
public function update(OptionVariableFormRequest $request, Egg $option, EggVariable $variable)
{
$this->updateService->handle($variable, $request->normalize());
$this->alert->success(trans('admin/services.variables.notices.variable_updated', [
'variable' => $variable->name,
]))->flash();
return redirect()->route('admin.services.option.variables', $option->id);
}
/**
* Delete a service variable from the system.
*
* @param \Pterodactyl\Models\Egg $option
* @param \Pterodactyl\Models\EggVariable $variable
* @return \Illuminate\Http\RedirectResponse
*/
public function delete(Egg $option, EggVariable $variable)
{
$this->serviceVariableRepository->delete($variable->id);
$this->alert->success(trans('admin/services.variables.notices.variable_deleted', [
'variable' => $variable->name,
]))->flash();
return redirect()->route('admin.services.option.variables', $option->id);
}
}

View file

@ -0,0 +1,49 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Http\Requests\Admin\Egg;
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
class EggFormRequest extends AdminFormRequest
{
/**
* {@inheritdoc}
*/
public function rules()
{
$rules = [
'name' => 'required|string|max:255',
'description' => 'required|string',
'docker_image' => 'required|string|max:255',
'startup' => 'required|string',
'config_from' => 'sometimes|bail|nullable|numeric',
'config_stop' => 'required_without:config_from|nullable|string|max:255',
'config_startup' => 'required_without:config_from|nullable|json',
'config_logs' => 'required_without:config_from|nullable|json',
'config_files' => 'required_without:config_from|nullable|json',
];
if ($this->method() === 'POST') {
$rules['nest_id'] = 'required|numeric|exists:nests,id';
}
return $rules;
}
/**
* @param \Illuminate\Contracts\Validation\Validator $validator
*/
public function withValidator($validator)
{
$validator->sometimes('config_from', 'exists:eggs,id', function () {
return (int) $this->input('config_from') !== 0;
});
}
}

View file

@ -7,11 +7,11 @@
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Http\Requests\Admin\Service;
namespace Pterodactyl\Http\Requests\Admin\Egg;
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
class EditOptionScript extends AdminFormRequest
class EggScriptFormRequest extends AdminFormRequest
{
/**
* Return the rules to be used when validating the sent data in the request.

View file

@ -7,11 +7,12 @@
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Http\Requests\Admin;
namespace Pterodactyl\Http\Requests\Admin\Egg;
use Pterodactyl\Models\EggVariable;
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
class OptionVariableFormRequest extends AdminFormRequest
class EggVariableFormRequest extends AdminFormRequest
{
/**
* @return array
@ -37,11 +38,9 @@ class OptionVariableFormRequest extends AdminFormRequest
{
$rules = $this->input('rules');
if ($this->method() === 'PATCH') {
$rules = $this->input('rules', $this->route()->parameter('variable')->rules);
$rules = $this->input('rules', $this->route()->parameter('egg')->rules);
}
$validator->sometimes('default_value', $rules, function ($input) {
return $input->default_value;
});
$validator->addRules(['default_value' => $rules]);
}
}

View file

@ -1,24 +0,0 @@
<?php
/**
* Pterodactyl - Panel
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
*
* This software is licensed under the terms of the MIT license.
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Http\Requests\Admin\Service;
use Pterodactyl\Models\Egg;
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
class ServiceOptionFormRequest extends AdminFormRequest
{
/**
* {@inheritdoc}
*/
public function rules()
{
return Egg::getCreateRules();
}
}

View file

@ -64,7 +64,7 @@ class Egg extends Model implements CleansAttributes, ValidableContract
* @var array
*/
protected static $applicationRules = [
'service_id' => 'required',
'nest_id' => 'required',
'name' => 'required',
'description' => 'required',
'docker_image' => 'required',
@ -80,13 +80,13 @@ class Egg extends Model implements CleansAttributes, ValidableContract
* @var array
*/
protected static $dataIntegrityRules = [
'service_id' => 'bail|numeric|exists:services,id',
'nest_id' => 'bail|numeric|exists:nests,id',
'uuid' => 'string|size:36',
'name' => 'string|max:255',
'description' => 'string',
'docker_image' => 'string|max:255',
'startup' => 'nullable|string',
'config_from' => 'bail|nullable|numeric|exists:service_options,id',
'config_from' => 'bail|nullable|numeric|exists:eggs,id',
'config_stop' => 'nullable|string|max:255',
'config_startup' => 'nullable|json',
'config_logs' => 'nullable|json',

View file

@ -7,17 +7,20 @@
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Services\Services\Options;
namespace Pterodactyl\Services\Eggs;
use Pterodactyl\Models\Egg;
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
class OptionConfigurationFileService
class EggConfigurationService
{
/**
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
*/
protected $repository;
/**
* OptionConfigurationFileService constructor.
* EggConfigurationService constructor.
*
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
*/
@ -27,7 +30,7 @@ class OptionConfigurationFileService
}
/**
* Return a service configuration file to be used by the daemon.
* Return an Egg file to be used by the Daemon.
*
* @param int|\Pterodactyl\Models\Egg $option
* @return array

View file

@ -7,15 +7,16 @@
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Services\Services\Options;
namespace Pterodactyl\Services\Eggs;
use Ramsey\Uuid\Uuid;
use Pterodactyl\Models\Egg;
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
use Illuminate\Contracts\Config\Repository as ConfigRepository;
use Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException;
use Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException;
class OptionCreationService
// When a mommy and a daddy pterodactyl really like eachother...
class EggCreationService
{
/**
* @var \Illuminate\Contracts\Config\Repository
@ -28,7 +29,7 @@ class OptionCreationService
protected $repository;
/**
* CreationService constructor.
* EggCreationService constructor.
*
* @param \Illuminate\Contracts\Config\Repository $config
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
@ -46,31 +47,25 @@ class OptionCreationService
* @return \Pterodactyl\Models\Egg
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException
* @throws \Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException
*/
public function handle(array $data): Egg
{
if (! is_null(array_get($data, 'config_from'))) {
$data['config_from'] = array_get($data, 'config_from');
if (! is_null($data['config_from'])) {
$results = $this->repository->findCountWhere([
['service_id', '=', array_get($data, 'service_id')],
['nest_id', '=', array_get($data, 'nest_id')],
['id', '=', array_get($data, 'config_from')],
]);
if ($results !== 1) {
throw new NoParentConfigurationFoundException(trans('exceptions.service.options.must_be_child'));
}
} else {
$data['config_from'] = null;
}
if (count($parts = explode(':', array_get($data, 'tag'))) > 1) {
$data['tag'] = $this->config->get('pterodactyl.service.author') . ':' . trim(array_pop($parts));
} else {
$data['tag'] = $this->config->get('pterodactyl.service.author') . ':' . trim(array_get($data, 'tag'));
}
return $this->repository->create(array_merge($data, [
'uuid' => Uuid::uuid4()->toString(),
'author' => $this->config->get('pterodactyl.service.author'),
]), true, true);
}
}

View file

@ -7,14 +7,14 @@
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Services\Services\Options;
namespace Pterodactyl\Services\Eggs;
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
use Pterodactyl\Exceptions\Service\Egg\HasChildrenException;
use Pterodactyl\Exceptions\Service\HasActiveServersException;
use Pterodactyl\Contracts\Repository\ServerRepositoryInterface;
use Pterodactyl\Exceptions\Service\ServiceOption\HasChildrenException;
class OptionDeletionService
class EggDeletionService
{
/**
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
@ -27,7 +27,7 @@ class OptionDeletionService
protected $serverRepository;
/**
* OptionDeletionService constructor.
* EggDeletionService constructor.
*
* @param \Pterodactyl\Contracts\Repository\ServerRepositoryInterface $serverRepository
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
@ -41,26 +41,26 @@ class OptionDeletionService
}
/**
* Delete an option from the database if it has no active servers attached to it.
* Delete an Egg from the database if it has no active servers attached to it.
*
* @param int $option
* @param int $egg
* @return int
*
* @throws \Pterodactyl\Exceptions\Service\HasActiveServersException
* @throws \Pterodactyl\Exceptions\Service\ServiceOption\HasChildrenException
* @throws \Pterodactyl\Exceptions\Service\Egg\HasChildrenException
*/
public function handle(int $option): int
public function handle(int $egg): int
{
$servers = $this->serverRepository->findCountWhere([['option_id', '=', $option]]);
$servers = $this->serverRepository->findCountWhere([['egg_id', '=', $egg]]);
if ($servers > 0) {
throw new HasActiveServersException(trans('exceptions.service.options.delete_has_servers'));
throw new HasActiveServersException(trans('exceptions.nest.egg.delete_has_servers'));
}
$children = $this->repository->findCountWhere([['config_from', '=', $option]]);
$children = $this->repository->findCountWhere([['config_from', '=', $egg]]);
if ($children > 0) {
throw new HasChildrenException(trans('exceptions.service.options.has_children'));
throw new HasChildrenException(trans('exceptions.nest.egg.has_children'));
}
return $this->repository->delete($option);
return $this->repository->delete($egg);
}
}

View file

@ -7,13 +7,13 @@
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Services\Services\Options;
namespace Pterodactyl\Services\Eggs;
use Pterodactyl\Models\Egg;
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
use Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException;
use Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException;
class OptionUpdateService
class EggUpdateService
{
/**
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
@ -21,7 +21,7 @@ class OptionUpdateService
protected $repository;
/**
* OptionUpdateService constructor.
* EggUpdateService constructor.
*
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
*/
@ -33,30 +33,30 @@ class OptionUpdateService
/**
* Update a service option.
*
* @param int|\Pterodactyl\Models\Egg $option
* @param int|\Pterodactyl\Models\Egg $egg
* @param array $data
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Pterodactyl\Exceptions\Service\ServiceOption\NoParentConfigurationFoundException
* @throws \Pterodactyl\Exceptions\Service\Egg\NoParentConfigurationFoundException
*/
public function handle($option, array $data)
public function handle($egg, array $data)
{
if (! $option instanceof Egg) {
$option = $this->repository->find($option);
if (! $egg instanceof Egg) {
$egg = $this->repository->find($egg);
}
if (! is_null(array_get($data, 'config_from'))) {
$results = $this->repository->findCountWhere([
['service_id', '=', $option->service_id],
['nest_id', '=', $egg->nest_id],
['id', '=', array_get($data, 'config_from')],
]);
if ($results !== 1) {
throw new NoParentConfigurationFoundException(trans('exceptions.service.options.must_be_child'));
throw new NoParentConfigurationFoundException(trans('exceptions.nest.egg.must_be_child'));
}
}
$this->repository->withoutFresh()->update($option->id, $data);
$this->repository->withoutFresh()->update($egg->id, $data);
}
}

View file

@ -7,13 +7,13 @@
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Services\Services\Options;
namespace Pterodactyl\Services\Eggs\Scripts;
use Pterodactyl\Models\Egg;
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
use Pterodactyl\Exceptions\Service\ServiceOption\InvalidCopyFromException;
use Pterodactyl\Exceptions\Service\Egg\InvalidCopyFromException;
class InstallScriptUpdateService
class InstallScriptService
{
/**
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
@ -21,7 +21,7 @@ class InstallScriptUpdateService
protected $repository;
/**
* InstallScriptUpdateService constructor.
* InstallScriptService constructor.
*
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $repository
*/
@ -31,30 +31,30 @@ class InstallScriptUpdateService
}
/**
* Modify the option install script for a given service option.
* Modify the install script for a given Egg.
*
* @param int|\Pterodactyl\Models\Egg $option
* @param int|\Pterodactyl\Models\Egg $egg
* @param array $data
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Pterodactyl\Exceptions\Service\ServiceOption\InvalidCopyFromException
* @throws \Pterodactyl\Exceptions\Service\Egg\InvalidCopyFromException
*/
public function handle($option, array $data)
public function handle($egg, array $data)
{
if (! $option instanceof Egg) {
$option = $this->repository->find($option);
if (! $egg instanceof Egg) {
$egg = $this->repository->find($egg);
}
if (! is_null(array_get($data, 'copy_script_from'))) {
if (! $this->repository->isCopiableScript(array_get($data, 'copy_script_from'), $option->service_id)) {
throw new InvalidCopyFromException(trans('exceptions.service.options.invalid_copy_id'));
if (! $this->repository->isCopiableScript(array_get($data, 'copy_script_from'), $egg->service_id)) {
throw new InvalidCopyFromException(trans('exceptions.nest.egg.invalid_copy_id'));
}
}
$this->repository->withoutFresh()->update($option->id, [
$this->repository->withoutFresh()->update($egg->id, [
'script_install' => array_get($data, 'script_install'),
'script_is_privileged' => array_get($data, 'script_is_privileged'),
'script_is_privileged' => array_get($data, 'script_is_privileged', 1),
'script_entry' => array_get($data, 'script_entry'),
'script_container' => array_get($data, 'script_container'),
'copy_script_from' => array_get($data, 'copy_script_from'),

View file

@ -7,50 +7,51 @@
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Services\Services\Variables;
namespace Pterodactyl\Services\Eggs\Variables;
use Pterodactyl\Models\Egg;
use Pterodactyl\Models\EggVariable;
use Pterodactyl\Contracts\Repository\EggRepositoryInterface;
use Pterodactyl\Contracts\Repository\ServiceVariableRepositoryInterface;
use Pterodactyl\Exceptions\Service\ServiceVariable\ReservedVariableNameException;
use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface;
use Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException;
class VariableCreationService
{
/**
* @var \Pterodactyl\Contracts\Repository\EggRepositoryInterface
*/
protected $serviceOptionRepository;
protected $eggRepository;
/**
* @var \Pterodactyl\Contracts\Repository\ServiceVariableRepositoryInterface
* @var \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface
*/
protected $serviceVariableRepository;
protected $variableRepository;
/**
* VariableCreationService constructor.
*
* @param \Pterodactyl\Contracts\Repository\EggRepositoryInterface $eggRepository
* @param \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface $variableRepository
*/
public function __construct(
EggRepositoryInterface $serviceOptionRepository,
ServiceVariableRepositoryInterface $serviceVariableRepository
EggRepositoryInterface $eggRepository,
EggVariableRepositoryInterface $variableRepository
) {
$this->serviceOptionRepository = $serviceOptionRepository;
$this->serviceVariableRepository = $serviceVariableRepository;
$this->eggRepository = $eggRepository;
$this->variableRepository = $variableRepository;
}
/**
* Create a new variable for a given service option.
* Create a new variable for a given Egg.
*
* @param int|\Pterodactyl\Models\Egg $option
* @param array $data
* @param int $egg
* @param array $data
* @return \Pterodactyl\Models\EggVariable
*
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Service\ServiceVariable\ReservedVariableNameException
* @throws \Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException
*/
public function handle($option, array $data)
public function handle(int $egg, array $data): EggVariable
{
if ($option instanceof Egg) {
$option = $option->id;
}
if (in_array(strtoupper(array_get($data, 'env_variable')), explode(',', EggVariable::RESERVED_ENV_NAMES))) {
throw new ReservedVariableNameException(sprintf(
'Cannot use the protected name %s for this environment variable.',
@ -60,8 +61,8 @@ class VariableCreationService
$options = array_get($data, 'options', []);
return $this->serviceVariableRepository->create(array_merge([
'option_id' => $option,
return $this->variableRepository->create(array_merge([
'egg_id' => $egg,
'user_viewable' => in_array('user_viewable', $options),
'user_editable' => in_array('user_editable', $options),
], $data));

View file

@ -7,32 +7,32 @@
* https://opensource.org/licenses/MIT
*/
namespace Pterodactyl\Services\Services\Variables;
namespace Pterodactyl\Services\Eggs\Variables;
use Pterodactyl\Models\EggVariable;
use Pterodactyl\Exceptions\DisplayException;
use Pterodactyl\Contracts\Repository\ServiceVariableRepositoryInterface;
use Pterodactyl\Exceptions\Service\ServiceVariable\ReservedVariableNameException;
use Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface;
use Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException;
class VariableUpdateService
{
/**
* @var \Pterodactyl\Contracts\Repository\ServiceVariableRepositoryInterface
* @var \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface
*/
protected $repository;
/**
* VariableUpdateService constructor.
*
* @param \Pterodactyl\Contracts\Repository\ServiceVariableRepositoryInterface $repository
* @param \Pterodactyl\Contracts\Repository\EggVariableRepositoryInterface $repository
*/
public function __construct(ServiceVariableRepositoryInterface $repository)
public function __construct(EggVariableRepositoryInterface $repository)
{
$this->repository = $repository;
}
/**
* Update a specific service variable.
* Update a specific egg variable.
*
* @param int|\Pterodactyl\Models\EggVariable $variable
* @param array $data
@ -41,7 +41,7 @@ class VariableUpdateService
* @throws \Pterodactyl\Exceptions\DisplayException
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
* @throws \Pterodactyl\Exceptions\Service\ServiceVariable\ReservedVariableNameException
* @throws \Pterodactyl\Exceptions\Service\Egg\Variable\ReservedVariableNameException
*/
public function handle($variable, array $data)
{
@ -58,7 +58,7 @@ class VariableUpdateService
$search = $this->repository->withColumns('id')->findCountWhere([
['env_variable', '=', array_get($data, 'env_variable')],
['option_id', '=', $variable->option_id],
['egg_id', '=', $variable->egg_id],
['id', '!=', $variable->id],
]);
@ -71,9 +71,9 @@ class VariableUpdateService
$options = array_get($data, 'options', []);
return $this->repository->withoutFresh()->update($variable->id, array_merge([
return $this->repository->withoutFresh()->update($variable->id, array_merge($data, [
'user_viewable' => in_array('user_viewable', $options),
'user_editable' => in_array('user_editable', $options),
], $data));
]));
}
}