34 lines
520 B
PHP
34 lines
520 B
PHP
<?php
|
|
|
|
/**
|
|
* Check if users have been switched
|
|
*/
|
|
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');
|
|
}
|
|
|
|
/**
|
|
* 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;
|
|
}
|
|
} |