Updated BlueprintExtensionController
Made the code look a bit better and added a way for the admin options to save. (I later realized I could have done this using a much easier way. I'm just built different and it works. If it aint broke don't fix it.)
This commit is contained in:
parent
25386b6a49
commit
af7b4c30cb
2 changed files with 69 additions and 3 deletions
|
@ -4,9 +4,15 @@ namespace Pterodactyl\Http\Controllers\Admin\Extensions\Blueprint;
|
||||||
|
|
||||||
use Illuminate\View\View;
|
use Illuminate\View\View;
|
||||||
use Illuminate\View\Factory as ViewFactory;
|
use Illuminate\View\Factory as ViewFactory;
|
||||||
|
use Prologue\Alerts\AlertsMessageBag;
|
||||||
|
use Illuminate\Contracts\Console\Kernel;
|
||||||
use Pterodactyl\Http\Controllers\Controller;
|
use Pterodactyl\Http\Controllers\Controller;
|
||||||
use Pterodactyl\Services\Helpers\SoftwareVersionService;
|
use Pterodactyl\Services\Helpers\SoftwareVersionService;
|
||||||
use Pterodactyl\Services\Helpers\BlueprintVariableService;
|
use Pterodactyl\Services\Helpers\BlueprintVariableService;
|
||||||
|
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
|
||||||
|
use Illuminate\Contracts\Config\Repository as ConfigRepository;
|
||||||
|
use Pterodactyl\Http\Requests\Admin\Extensions\Blueprint\BlueprintSettingsFormRequest;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
|
||||||
class BlueprintExtensionController extends Controller
|
class BlueprintExtensionController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -14,8 +20,16 @@ class BlueprintExtensionController extends Controller
|
||||||
/**
|
/**
|
||||||
* BlueprintExtensionController constructor.
|
* BlueprintExtensionController constructor.
|
||||||
*/
|
*/
|
||||||
public function __construct(private SoftwareVersionService $version, private ViewFactory $view, private BlueprintVariableService $bp)
|
public function __construct(
|
||||||
{
|
private BlueprintVariableService $bp,
|
||||||
|
|
||||||
|
private SoftwareVersionService $version,
|
||||||
|
private ViewFactory $view,
|
||||||
|
private Kernel $kernel,
|
||||||
|
private AlertsMessageBag $alert,
|
||||||
|
private ConfigRepository $config,
|
||||||
|
private SettingsRepositoryInterface $settings,
|
||||||
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,6 +39,29 @@ class BlueprintExtensionController extends Controller
|
||||||
{
|
{
|
||||||
$rootPath = "/admin/extensions/blueprint";
|
$rootPath = "/admin/extensions/blueprint";
|
||||||
$license = $this->bp->licenseIsValid();
|
$license = $this->bp->licenseIsValid();
|
||||||
return $this->view->make('admin.extensions.blueprint.index', ['version' => $this->version, 'bp' => $this->bp, 'root' => $rootPath, 'license' => $license]);
|
return $this->view->make(
|
||||||
|
'admin.extensions.blueprint.index', [
|
||||||
|
'version' => $this->version,
|
||||||
|
'bp' => $this->bp,
|
||||||
|
'root' => $rootPath,
|
||||||
|
'license' => $license
|
||||||
|
]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
||||||
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
||||||
|
*/
|
||||||
|
public function update(BlueprintSettingsFormRequest $request): RedirectResponse
|
||||||
|
{
|
||||||
|
foreach ($request->normalize() as $key => $value) {
|
||||||
|
$this->settings->set('blueprint::' . $key, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
//$this->kernel->call('queue:restart');
|
||||||
|
//$this->alert->success('Blueprint settings have updated successfully.')->flash();
|
||||||
|
|
||||||
|
return redirect()->route('admin.extensions.blueprint.index');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Pterodactyl\Http\Requests\Admin\Extensions\Blueprint;
|
||||||
|
|
||||||
|
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
|
||||||
|
|
||||||
|
class BlueprintSettingsFormRequest extends AdminFormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Return all the rules to apply to this request's data.
|
||||||
|
*/
|
||||||
|
public function rules(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'placeholder:1' => 'string',
|
||||||
|
'placeholder:2' => 'string',
|
||||||
|
'placeholder:3' => 'string',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function attributes(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'placeholder:1' => 'placeholder one',
|
||||||
|
'placeholder:2' => 'placeholder two',
|
||||||
|
'placeholder:3' => 'placeholder three',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue