Skip to content

Commit

Permalink
Dynamically fetch user from Sentinel.
Browse files Browse the repository at this point in the history
User info may not be populated in Controller constructors.
We'll fetch it on demand to avoid non-object issues.
  • Loading branch information
Jiaquan He committed Aug 4, 2020
1 parent 8af75e9 commit ee0157d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/Http/Controllers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ class Controller extends BaseController

public function __construct()
{
$this->user = Sentinel::getUser();
}

public function __get($property)
{
if ($property == 'user') {
return Sentinel::getUser();
}
}

public function arrange($data)
Expand Down

0 comments on commit ee0157d

Please sign in to comment.