Reputation:
I have this code:
if(Auth::check()) {
Redirect::to('home');
}
$user = Auth::user();
return View::make('HumanResourcesProcess')->with(array('firstName', $user->firstName));
and it gives me the error:
Undefined variable: firstName
But I am defining it in the array part? Any ideas on how to fix it?
Upvotes: 0
Views: 58
Reputation: 676
Another alternative you can use is 'compact', especially useful if you have lot's of variable to pass without having to assign them when passing to view:
return View::make('view.name',compact('variable1','variable2','variable3'));
Upvotes: 0
Reputation: 823
Try this:
return View::make('HumanResourcesProcess')->with('firstName', $user->firstName);
or this one:
return View::make('HumanResourcesProcess')->with(array('firstName' => $user->firstName) );
I hope it works fine.
Upvotes: 2