2014-08-04 09:39 阅读 83


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

    public function index(){
        $this->layout->title = 'Index Title';
        return View::make('pages.index');

But when I load the page return this error: enter image description here

And in my 'app\views\layout\base.blade.php' i have:

<!DOCTYPE html>
<html lang="es">


This is my route.php:

Route::get('/index',['as' => 'pages.index', 'uses' => 'WebController@index']);

How to fix this? Thank you very much!

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

3条回答 默认 最新

  • 已采纳
    drvvvuyia15070493 drvvvuyia15070493 2014-08-04 09:52

    Try to add an array with data to the view::make:

    return View::make('pages.index', array('title' => 'Title'));
    点赞 评论 复制链接分享
  • douzuanze0486 douzuanze0486 2014-08-04 09:47

    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.

        public function index(){
            $title = 'Index Title';
            return View::make('pages.index', $title);

    Example with compact();

    return View::make('pages.index', compact('title','description'));
    点赞 评论 复制链接分享
  • dongtuoao7987 dongtuoao7987 2014-08-04 11:54

    try to write call your view from

    return View::make('pages.index'); 


    return View::make('pages.index')->with('title', $this->layout->title);
    点赞 评论 复制链接分享