peliprint/app/BlueprintFramework/Controllers/ExtensionConfigurationController.php

44 lines
1.5 KiB
PHP
Raw Normal View History

<?php
namespace Pterodactyl\BlueprintFramework\Controllers;
use Pterodactyl\Http\Controllers\Controller;
use Illuminate\Http\RedirectResponse;
use Pterodactyl\Http\Requests\Admin\AdminFormRequest;
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
class ExtensionConfigurationController extends Controller
{
/**
* BlueprintExtensionController constructor.
*/
public function __construct(private SettingsRepositoryInterface $settings,) {}
/**
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
*/
public function update(ExtensionConfigurationRequest $request): RedirectResponse
{
2024-03-19 12:58:06 -04:00
foreach ($request->normalize() as $key => $value) { $this->settings->set('blueprint::extensionconfig_' . $key, $value); }
return redirect()->route('admin.extensions.'.$request->input('_identifier', 'blueprint').'.index');
}
}
class ExtensionConfigurationRequest extends AdminFormRequest
{
public function rules(): array {
return [
$this->input('_identifier', 'blueprint').'_adminlayouts' => 'boolean',
$this->input('_identifier', 'blueprint').'_dashboardwrapper' => 'boolean',
];
}
public function attributes(): array {
return [
$this->input('_identifier', 'blueprint').'_adminlayouts' => 'admin layouts permission',
$this->input('_identifier', 'blueprint').'_dashboardwrapper' => 'dashboard wrapper permission',
];
}
}