When I ask if(Auth::user()->role == "xxxx") inside CandidateEvent displays "Trying to get property of non-object"
The problem is that component Auth::user() isn't working in my Event.
What is the correct way to use Auth within Events?
public function __construct()
{
if(Auth::user()->role == "XXXX")
{
$candidate = count(Candidate::CountNewCandidate());
}
else
{
$candidate = count(Candidate::CountNewCandidateGroup());
}
$this->data = [ 'cCandidate' => $candidate ];
}