62 lines
1.6 KiB
PHP
62 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Http\Controllers\Admin;
|
|
|
|
use App\CMS\Repositories\Settings\Settings as SettingsRepository;
|
|
use App\Http\Requests;
|
|
use App\Models\Settings as SettingsModel;
|
|
use Illuminate\Support\Facades\App;
|
|
|
|
class Settings extends Controller
|
|
{
|
|
/**
|
|
* @var SettingsRepository
|
|
*/
|
|
protected $settings;
|
|
|
|
/**
|
|
* Settings constructor.
|
|
*
|
|
* @param SettingsModel $settings
|
|
*/
|
|
public function __construct(SettingsRepository $settings)
|
|
{
|
|
$this->settings = $settings;
|
|
}
|
|
|
|
/**
|
|
* Get overview (with form) for editing settings
|
|
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
|
|
*/
|
|
public function getOverview()
|
|
{
|
|
$sections = App::make('registerSettingsExtension')
|
|
->get();
|
|
|
|
// load all settings with language info
|
|
$settings = $this->settings->getAllWithLanguage();
|
|
|
|
return view('admin.settings.overview', [
|
|
'formSections' => $sections,
|
|
'settings' => $settings
|
|
]);
|
|
}
|
|
|
|
/**
|
|
* Save all settings (ignore empty ones)
|
|
* When settings used to be non-empty string and user deletes it, key is also deleted from database
|
|
*
|
|
* @param Requests\SaveSettingsRequest $request
|
|
*
|
|
* @return \Illuminate\Http\RedirectResponse
|
|
*/
|
|
public function saveSettings(Requests\SaveSettingsRequest $request)
|
|
{
|
|
$this->settings->save($request->except(['_token']));
|
|
|
|
return redirect()
|
|
->route('settings.overview')
|
|
->with('success', trans('admin/settings.successfullySaved'));
|
|
}
|
|
}
|