そのため、コントローラーでレイアウトを機能させるには、最初content
にレイアウト ブレード テンプレートで変数を宣言する必要があります。
コントローラーで既に行ったことを行いますが、ビューでディレクトリ構造を操作するときはドット表記を覚えておいてください。layouts.master は、layouts/master.blade.php と同じです。
class UserController extends BaseController {
/**
* The layout that should be used for responses.
*/
protected $layout = 'layouts.master';
public function getIndex()
{
// Remember dot notation when building views
$this->layout->content = View::make('authentication.login')
->with('page_title','title');
}
}
layouts/master.blade.php内
<div class="content">
{{-- This is the content variable used for the layout --}}
{{ $content }}
</div>
authentication/login.blade.phpで
<title>{{ $page_title }}</title>
この構造を使用すると、これが機能します。