FleetCart/Modules/Setting/Http/Controllers/Admin/SettingController.php

54 lines
1.3 KiB
PHP
Raw Normal View History

2023-06-11 12:14:03 +00:00
<?php
namespace Modules\Setting\Http\Controllers\Admin;
2023-12-03 14:07:47 +00:00
use Illuminate\Http\Request;
use Illuminate\Http\Response;
2023-06-11 12:14:03 +00:00
use Illuminate\Support\Facades\Artisan;
use Modules\Admin\Ui\Facades\TabManager;
use Modules\Setting\Http\Requests\UpdateSettingRequest;
class SettingController
{
/**
* Show the form for editing the specified resource.
*
2023-12-03 14:07:47 +00:00
* @return Response
2023-06-11 12:14:03 +00:00
*/
public function edit()
{
$settings = setting()->all();
$tabs = TabManager::get('settings');
return view('setting::admin.settings.edit', compact('settings', 'tabs'));
}
2023-12-03 14:07:47 +00:00
2023-06-11 12:14:03 +00:00
/**
* Update the specified resource in storage.
*
2023-12-03 14:07:47 +00:00
* @param Request $request
*
* @return Response
2023-06-11 12:14:03 +00:00
*/
public function update(UpdateSettingRequest $request)
{
$this->handleMaintenanceMode($request);
setting($request->except('_token', '_method'));
return redirect(non_localized_url())
2023-12-03 14:07:47 +00:00
->with('success', trans('setting::messages.settings_updated'));
2023-06-11 12:14:03 +00:00
}
2023-12-03 14:07:47 +00:00
2023-06-11 12:14:03 +00:00
private function handleMaintenanceMode($request)
{
if ($request->maintenance_mode) {
Artisan::call('down');
2023-12-03 14:07:47 +00:00
} else if (app()->isDownForMaintenance()) {
2023-06-11 12:14:03 +00:00
Artisan::call('up');
}
}
}