我有一个没有控制器的应用程序,并在laravel 4 文档和其他文章中阅读了有关控制器布局的信息,但我不知道从哪里开始在路由(版本 4)中实现它,我该怎么做?
收到错误:InvalidArgumentException,未找到视图 [master]。
应用程序/routes.php
<?php
View::name('layouts.master', 'layout');
$layout = View::of('layout');
Route::get('users/create', array('as' => 'users.create', function() use($layout) {
//@TODO: load view using 'layouts.master',
// desirable: append 'users.create' and 'users.menu' views to sidebar and content sections.
//return View::make('users.create');
return $layout->nest('content', 'master');
}));
?>
应用程序/视图/布局/master.blade.php
<html>
<body>
@section('sidebar')
This is the master sidebar.
@show
<div class="container">
@yield('content')
</div>
</body>
</html>
应用程序/视图/用户/create.blade.php
{{ Form::open() }}
{{ Form::text('name') }}
{{ Form::submit('submit') }}
{{ Form::close() }}
应用程序/视图/用户/menu.blade.php
<!-- This is appended to the master sidebar -->
<p><a href="users/create">Create user</a></p>
更新:我修改了示例代码以阐明我想要做什么。检查app/routes.php
及其评论