2022-10-03 17:13:44 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Bo;
|
|
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
|
use App\Http\Requests\Bo\UpdateGeneralConfigRequest;
|
|
|
|
|
use App\Models\GeneralConfig;
|
|
|
|
|
|
|
|
|
|
class GeneralConfigController extends Controller
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* General config index
|
|
|
|
|
*
|
|
|
|
|
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
|
|
|
|
*/
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
2023-02-06 17:14:58 +01:00
|
|
|
/** @var \Illuminate\Pagination\LengthAwarePaginator $configList */
|
|
|
|
|
$configList = GeneralConfig::query()->where('data', '!=', '[]')->paginate();
|
|
|
|
|
return view('back::pages.general-configs.index', compact('configList'));
|
2022-10-03 17:13:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Edit general config
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Models\GeneralConfig $config
|
|
|
|
|
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factor
|
|
|
|
|
*/
|
|
|
|
|
public function edit(GeneralConfig $config)
|
|
|
|
|
{
|
2023-01-30 17:46:30 +01:00
|
|
|
return view('back::pages.general-configs.edit', ['config' => $config]);
|
2022-10-03 17:13:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Update General
|
|
|
|
|
*
|
|
|
|
|
* @param \App\Http\Requests\UpdateGeneralConfigRequest $request
|
|
|
|
|
* @param \App\Models\GeneralConfig $config
|
|
|
|
|
* @return voi\Illuminate\Http\RedirectResponse
|
|
|
|
|
*/
|
|
|
|
|
public function update(UpdateGeneralConfigRequest $request, GeneralConfig $config)
|
|
|
|
|
{
|
|
|
|
|
$config->fill(array_replace_recursive(
|
|
|
|
|
\json_decode(\json_encode($config->toArray()), true),
|
|
|
|
|
$request->validated()
|
|
|
|
|
));
|
|
|
|
|
$config->saveOrFail();
|
|
|
|
|
return redirect()->route('bo.general_configs.edit', $config)
|
|
|
|
|
->with('success', 'Enregistré !');
|
|
|
|
|
}
|
|
|
|
|
}
|