2015-08-30 16:31:16 +02:00
|
|
|
<?php
|
|
|
|
|
2015-09-10 20:31:09 +02:00
|
|
|
namespace BookStack\Http\Controllers;
|
2015-08-30 16:31:16 +02:00
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
2015-09-10 20:31:09 +02:00
|
|
|
use BookStack\Http\Requests;
|
|
|
|
use BookStack\Http\Controllers\Controller;
|
2015-08-30 16:31:16 +02:00
|
|
|
use Setting;
|
|
|
|
|
|
|
|
class SettingController extends Controller
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Display a listing of the settings.
|
|
|
|
*
|
|
|
|
* @return Response
|
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$this->checkPermission('settings-update');
|
2015-12-05 15:41:51 +01:00
|
|
|
$this->setPageTitle('Settings');
|
2015-08-30 16:31:16 +02:00
|
|
|
return view('settings/index');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the specified settings in storage.
|
|
|
|
*
|
|
|
|
* @param Request $request
|
|
|
|
* @return Response
|
|
|
|
*/
|
|
|
|
public function update(Request $request)
|
|
|
|
{
|
2015-12-31 18:57:34 +01:00
|
|
|
$this->preventAccessForDemoUsers();
|
2015-08-30 16:31:16 +02:00
|
|
|
$this->checkPermission('settings-update');
|
2015-12-31 18:57:34 +01:00
|
|
|
|
2015-08-30 16:31:16 +02:00
|
|
|
// Cycles through posted settings and update them
|
|
|
|
foreach($request->all() as $name => $value) {
|
|
|
|
if(strpos($name, 'setting-') !== 0) continue;
|
|
|
|
$key = str_replace('setting-', '', trim($name));
|
|
|
|
Setting::put($key, $value);
|
|
|
|
}
|
2015-12-31 18:57:34 +01:00
|
|
|
|
2015-09-05 21:25:57 +02:00
|
|
|
session()->flash('success', 'Settings Saved');
|
2015-08-30 16:31:16 +02:00
|
|
|
return redirect('/settings');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|