Today I started porting my app to the Laravel 4.3 structure, and a problem came out... In my BaseController, in the setupLayout method, I have a couple of View::share declaration, but once I try to open the website, I get an error that say Undefined variable: currentUser (this is one of the variable shared from the BaseController).
Was there any change to View::share with the 4.3 update, or maybe with the setupLayout on the controller... I can't find the problem anywhere...
Here's the setupLayout method and the stack trace:
/**
* Setup the layout used by the controller.
*
* @return void
*/
protected function setupLayout()
{
if ( ! is_null($this->layout))
{
$this->layout = View::make($this->layout);
}
View::share([
'currentUser' => Auth::user(),
'errorsTemplate' => '<span class="glyphicon glyphicon-remove form-control-feedback"></span> <span class="help-block">:message</span>'
]);
}
Next exception 'ErrorException' with message 'Undefined variable: currentUser (View: /home/vagrant/Code/cookbook/resources/views/layouts/partials/nav.blade.php) (View: /home/vagrant/Code/cookbook/resources/views/layouts/partials/nav.blade.php) (View: /home/vagrant/Code/cookbook/resources/views/layouts/partials/nav.blade.php)' in /home/vagrant/Code/cookbook/storage/views/f1f2308e03e0c0d48b16b8ba7f6f02fb:21
Stack trace:
#0 /home/vagrant/Code/cookbook/vendor/laravel/framework/src/Illuminate/View/Engines/PhpEngine.php(39): Illuminate\View\Engines\CompilerEngine->handleViewException(Object(ErrorException))
#1 /home/vagrant/Code/cookbook/vendor/laravel/framework/src/Illuminate/View/Engines/CompilerEngine.php(56): Illuminate\View\Engines\PhpEngine->evaluatePath('/home/vagrant/C...', Array)
#2 /home/vagrant/Code/cookbook/vendor/laravel/framework/src/Illuminate/View/View.php(135): Illuminate\View\Engines\CompilerEngine->get('/home/vagrant/C...', Array)
#3 /home/vagrant/Code/cookbook/vendor/laravel/framework/src/Illuminate/View/View.php(103): Illuminate\View\View->getContents()
#4 /home/vagrant/Code/cookbook/vendor/laravel/framework/src/Illuminate/View/View.php(77): Illuminate\View\View->renderContents()
#5 /home/vagrant/Code/cookbook/vendor/laravel/framework/src/Illuminate/Http/Response.php(43): Illuminate\View\View->render()
#6 /home/vagrant/Code/cookbook/vendor/symfony/http-foundation/Symfony/Component/HttpFoundation/Response.php(202): Illuminate\Http\Response->setContent(Object(Illuminate\View\View))
#7 /home/vagrant/Code/cookbook/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1500): Symfony\Component\HttpFoundation\Response->__construct(Object(Illuminate\View\View))
#8 /home/vagrant/Code/cookbook/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1031): Illuminate\Routing\Router->prepareResponse(Object(Illuminate\Http\Request), Object(Illuminate\View\View))
#9 /home/vagrant/Code/cookbook/vendor/laravel/framework/src/Illuminate/Routing/Router.php(994): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#10 /home/vagrant/Code/cookbook/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(827): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#11 /home/vagrant/Code/cookbook/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(804): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#12 /home/vagrant/Code/cookbook/vendor/laravel/framework/src/Illuminate/Session/Middleware.php(72): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#13 /home/vagrant/Code/cookbook/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php(47): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#14 /home/vagrant/Code/cookbook/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php(51): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#15 /home/vagrant/Code/cookbook/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#16 /home/vagrant/Code/cookbook/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(660): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#17 /home/vagrant/Code/cookbook/public/index.php(49): Illuminate\Foundation\Application->run()
#18 {main} [] []