传递数据以查看不工作 - Laravel 4

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?

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.

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'));