Reputation: 1005
i am new to larvel.I tried to pass the variable from controller toview but it did not worked. i am getting an error:
"Whoops, looks like something went wrong."
code used in controller:
public function showWelcome()
{
return View::make('hello', array('theLocation' => 'NYC'));
}
Code in hello.blade.php:
<h1 class="highlight">Blade has arrived in {{ $theLocation }} .</h1>
can you tell me is there any syntax error in the above code and is there any possibility of debugging the error??
Upvotes: 2
Views: 2588
Reputation: 26288
There are many ways to pass data from Controller to View like:
return view('hello')->with(['key' => 'value']);
or
return view('hello', ['key' => 'value']);
And you can use it on view like:
<p>{{ $key }}</p>
Upvotes: 2
Reputation: 4076
Controller
return view('hello')->with(['theLocation' => 'NYC']);
View
<h1 class="highlight">Blade has arrived in {{ $theLocation }} .</h1>
Upvotes: 1