Rename AdminController to SwitchUserController with some optimisations

This commit is contained in:
Deon George
2022-06-28 21:40:13 +10:00
parent b3471f31a0
commit c9cd560b36
3 changed files with 76 additions and 55 deletions

View File

@@ -7,14 +7,27 @@ namespace Leenooks\Traits;
use Session;
use App\Models\User;
trait UserSwitch
{
/**
* Return if this is a switched user
*
* @return mixed
*/
public function getSwitchedAttribute()
{
return Session::get('orig_user');
}
public function isAdmin($id)
/**
* If the user record has an admin attribute, we'll return that
*
* @param User|null $user
* @return false|mixed
*/
public function isAdmin(User $user=NULL)
{
return isset($this->admin) ? $this->admin : FALSE;
}