Laravel: Access the Logged-in User's ID in Your Master Pages
If you are searching for a way to access the current user's ID in you master pages, adding a view creator to your BaseController does the trick. This will make the variable $current_user available in all master pages contained in the views/layouts directory.
class BaseController extends Controller {
protected function setupLayout() {
View::creator('layouts.*', function($view) {
$view->with('current_user', Auth::id());
});
if ( ! is_null($this->layout)) {
$this->layout = View::make($this->layout);
}
}
}