Enable user switching
This commit is contained in:
31
app/Traits/UserSwitch.php
Normal file
31
app/Traits/UserSwitch.php
Normal file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Check if users have been switched
|
||||
*/
|
||||
namespace App\Traits;
|
||||
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
||||
trait UserSwitch
|
||||
{
|
||||
/**
|
||||
* Who is the original user
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getSwitchedAttribute()
|
||||
{
|
||||
return Session::get('orig_user');
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this user an admin
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isAdmin(): bool
|
||||
{
|
||||
return (bool)$this->admin ?? FALSE;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user