<?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; } }