Created
March 6, 2014 05:45
-
-
Save abdullah353/9383274 to your computer and use it in GitHub Desktop.
Share Variable with all views:
Now I have access to the currently logged in user as $user in all views, and can access anything from it as normal, such as $user->email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BaseController extends Controller | |
{ | |
public function __construct() | |
{ | |
// Fetch the User object, or set it to false if not logged in | |
if (Sentry::check()) { | |
$user = User::find(Sentry::getUser()–>id); | |
} | |
else { | |
$user = false; | |
} | |
// Sharing is caring | |
View::share('user', $user); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment