From aceed3d13b9f406d9707d242b3350445dac2e676 Mon Sep 17 00:00:00 2001 From: Chris Date: Mon, 15 Oct 2018 14:35:14 +0100 Subject: [PATCH] fix settings edit not working --- app/Http/Controllers/SettingsController.php | 2 +- app/Http/Middleware/CheckAllowed.php | 2 ++ app/Setting.php | 8 ++++++-- resources/views/layouts/app.blade.php | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index b44e366d..8b0af5e9 100644 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -13,6 +13,7 @@ class SettingsController extends Controller { public function __construct() { + $this->middleware('allowed'); } /** @@ -20,7 +21,6 @@ class SettingsController extends Controller */ public function index() { - User::checkAuthOrLogin(); $settings = SettingGroup::with([ 'settings', ])->orderBy('order', 'ASC')->get(); diff --git a/app/Http/Middleware/CheckAllowed.php b/app/Http/Middleware/CheckAllowed.php index 249967e1..59f8e68d 100644 --- a/app/Http/Middleware/CheckAllowed.php +++ b/app/Http/Middleware/CheckAllowed.php @@ -29,6 +29,8 @@ class CheckAllowed } if($route == 'dash') { + //print_r(User::all()); + //die("here".var_dump($current_user->password)); if((bool)$current_user->public_front === true) return $next($request); } diff --git a/app/Setting.php b/app/Setting.php index 11edd04e..dfe8d592 100644 --- a/app/Setting.php +++ b/app/Setting.php @@ -88,8 +88,12 @@ class Setting extends Model public function getEditValueAttribute() { - $user = $this->user(); - $this->value = $this->users()->where('id', $user->id)->first()->pivot->value; + if((bool)$this->system === true) { + $value = self::_fetch($this->key); + } else { + $value = self::fetch($this->key); + } + $this->value = $value; switch($this->type) { case 'image': $value = ''; diff --git a/resources/views/layouts/app.blade.php b/resources/views/layouts/app.blade.php index c87c2b96..0455a33a 100644 --- a/resources/views/layouts/app.blade.php +++ b/resources/views/layouts/app.blade.php @@ -71,7 +71,7 @@ @endif - Switch User + Switch User @yield('content')
@@ -81,7 +81,9 @@ @endif + @if(App\User::currentUser()->id === 1) + @endif