- require composer kwaadpepper/enum - User->role is now an enum - Add isLocal and isAdmin to user model - changed multiple fields casts on model Settings - added validation for settings
54 lines
1.6 KiB
PHP
54 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Bo;
|
|
|
|
use App\Http\Controllers\Controller;
|
|
use App\Http\Requests\Bo\UpdateSettingsRequest;
|
|
use App\Models\Settings;
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Illuminate\Support\Facades\Session;
|
|
|
|
class SettingsController extends Controller
|
|
{
|
|
/**
|
|
* Show edit settings page
|
|
*
|
|
* @return \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory
|
|
*/
|
|
public function manage()
|
|
{
|
|
/** @var \App\Models\Settings $settings */
|
|
$settings = app(Settings::class);
|
|
|
|
return view('bo.settings.manage', compact('settings'));
|
|
}
|
|
|
|
/**
|
|
* Save settings
|
|
*
|
|
* @param UpdateSettingsRequest $request
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function manageSubmit(UpdateSettingsRequest $request)
|
|
{
|
|
/** @var \App\Models\Settings $settings */
|
|
$settings = app(Settings::class);
|
|
|
|
$settings->fill($request->validated());
|
|
|
|
$redirectClose = $request->redirect_close;
|
|
// Check du lien de redirection après fermeture.
|
|
if (strpos($redirectClose, 'https://') === false && strpos($redirectClose, 'http://') === false) {
|
|
$redirectClose = 'https://' . $redirectClose;
|
|
}
|
|
$settings->redirect_close = $redirectClose;
|
|
|
|
if ($settings->saveOrFail()) {
|
|
$settingsGlobal = app(Settings::class)
|
|
->select('name', 'company', 'analytics', 'start_date', 'end_date')->first();
|
|
Cache::put('settingsGlobal', $settingsGlobal);
|
|
Session::flash('success', 'Modifications enregistrés !');
|
|
}
|
|
return \back();
|
|
}
|
|
}
|