2017-12-15 03:05:26 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Pterodactyl\Http\Controllers\Admin\Settings;
|
|
|
|
|
|
|
|
use Illuminate\View\View;
|
|
|
|
use Illuminate\Http\RedirectResponse;
|
|
|
|
use Prologue\Alerts\AlertsMessageBag;
|
|
|
|
use Illuminate\Contracts\Console\Kernel;
|
|
|
|
use Pterodactyl\Http\Controllers\Controller;
|
|
|
|
use Pterodactyl\Traits\Helpers\AvailableLanguages;
|
|
|
|
use Pterodactyl\Services\Helpers\SoftwareVersionService;
|
|
|
|
use Pterodactyl\Contracts\Repository\SettingsRepositoryInterface;
|
|
|
|
use Pterodactyl\Http\Requests\Admin\Settings\BaseSettingsFormRequest;
|
|
|
|
|
|
|
|
class IndexController extends Controller
|
|
|
|
{
|
|
|
|
use AvailableLanguages;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IndexController constructor.
|
|
|
|
*/
|
|
|
|
public function __construct(
|
2022-10-14 16:59:20 +00:00
|
|
|
private AlertsMessageBag $alert,
|
|
|
|
private Kernel $kernel,
|
|
|
|
private SettingsRepositoryInterface $settings,
|
2022-11-28 16:56:03 +00:00
|
|
|
private SoftwareVersionService $versionService
|
2021-01-23 21:44:35 +00:00
|
|
|
) {
|
2017-12-15 03:05:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Render the UI for basic Panel settings.
|
|
|
|
*/
|
|
|
|
public function index(): View
|
|
|
|
{
|
2022-11-28 16:56:03 +00:00
|
|
|
return view('admin.settings.index', [
|
2017-12-15 03:05:26 +00:00
|
|
|
'version' => $this->versionService,
|
|
|
|
'languages' => $this->getAvailableLanguages(true),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle settings update.
|
|
|
|
*
|
2018-05-13 16:19:35 +00:00
|
|
|
* @throws \Pterodactyl\Exceptions\Model\DataValidationException
|
|
|
|
* @throws \Pterodactyl\Exceptions\Repository\RecordNotFoundException
|
2017-12-15 03:05:26 +00:00
|
|
|
*/
|
|
|
|
public function update(BaseSettingsFormRequest $request): RedirectResponse
|
|
|
|
{
|
|
|
|
foreach ($request->normalize() as $key => $value) {
|
|
|
|
$this->settings->set('settings::' . $key, $value);
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->kernel->call('queue:restart');
|
|
|
|
$this->alert->success('Panel settings have been updated successfully and the queue worker was restarted to apply these changes.')->flash();
|
|
|
|
|
|
|
|
return redirect()->route('admin.settings');
|
|
|
|
}
|
|
|
|
}
|