I´m define my method controller index() and I pass param title for show in my html view:
class WebController extends BaseController{
public $layout = 'layout.base';
/*Index*/
public function index(){
$this->layout->title = 'Index Title';
return View::make('pages.index');
}
}
But when I load the page return this error:
And in my 'app\views\layout\base.blade.php' i have:
<!DOCTYPE html>
<html lang="es">
<head>
<title>{{$title}}</title>
@section('metas')
@show
@section('styles')
@show
</head>
This is my route.php:
Route::get('/index',['as' => 'pages.index', 'uses' => 'WebController@index']);
How to fix this? Thank you very much!
Try to add an array with data to the view::make
:
return View::make('pages.index', array('title' => 'Title'));
Try something like this, you have to pass the variable when you return the View::make(..). When you would like to pass more variables you can use the compact(); function.
/*Index*/
public function index(){
$title = 'Index Title';
return View::make('pages.index', $title);
}
Example with compact();
return View::make('pages.index', compact('title','description'));
try to write call your view from
return View::make('pages.index');
to
return View::make('pages.index')->with('title', $this->layout->title);