More improvements to User Switch

This commit is contained in:
Deon George 2018-07-17 13:27:25 +10:00
parent ac867a2526
commit 55cbe4087c
No known key found for this signature in database
GPG Key ID: 7670E8DC27415254
3 changed files with 10 additions and 5 deletions

View File

@ -45,7 +45,7 @@
<!-- Top Menu Items --> <!-- Top Menu Items -->
@include('adminlte::layouts.partials.topmenu') @include('adminlte::layouts.partials.topmenu')
<li class="dropdown user user-menu @if($user->switched()) bg-red @endif" id="user_menu"> <li class="dropdown user user-menu @if($user->switched) bg-red @endif" id="user_menu">
<!-- Menu Toggle Button --> <!-- Menu Toggle Button -->
<a href="#" class="dropdown-toggle" data-toggle="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">
<!-- The user image in the navbar--> <!-- The user image in the navbar-->
@ -69,7 +69,7 @@
</div> </div>
<div class="pull-right"> <div class="pull-right">
@if ($user->switched()) @if ($user->switched)
<a href="{{ url('/admin/switch/stop') }}" class="btn btn-default btn-flat" id="switch"> <a href="{{ url('/admin/switch/stop') }}" class="btn btn-default btn-flat" id="switch">
{{ trans('adminlte_lang::message.switchoff') }} {{ trans('adminlte_lang::message.switchoff') }}
</a> </a>

View File

@ -18,7 +18,7 @@ class AdminController extends Controller
public function switch_authorised() public function switch_authorised()
{ {
return TRUE; return Auth::user()->isAdmin ? TRUE : FALSE;
} }
public function switch_session() public function switch_session()

View File

@ -9,7 +9,12 @@ use Session;
trait UserSwitch trait UserSwitch
{ {
public function switched() public function GetIsAdminAttribute()
{
return isset($this->admin) ? $this->admin : FALSE;
}
public function getSwitchedAttribute()
{ {
return Session::get('orig_user'); return Session::get('orig_user');
} }