Laravel 4.1文件夹布局在视图文件夹

时间:2015-06-04 23:47:31

标签: php laravel-4

Laravel 4.1是否在layouts内附带views文件夹,还是应手动创建?

我自己制作了一个,但现在我的模板还没有工作。

FYI用作曲家安装了Laravel。

我想实现下面的代码模板,包含2个文件:

user.blade.php(placed in app/views/layouts/user.blade.php)

    <!doctype html>
    <html>
        @section('lib')
        <head>
        <meta charset="utf-8">
        <link href="//netdna.bootstrapcdn.com/twitter-bootstrap
     /2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
        <style>
            table form { margin-bottom: 0; }
            form ul { margin-left: 0; list-style: none; }
            .error { color: red; font-style: italic; }
            body { padding-top: 20px; }
        </style>
    </head>
    @stop
    <body>

        <div class="container">
            @if (Session::has('message'))
                <div class="flash alert">
                    <p>{{ Session::get('message') }}</p>
                </div>
            @endif

            @yield('main')
        </div>

    </body>

</html>

我希望将它实现为index.blade.php(app / views / user / index.blade.php)

@extends('layouts.user')

@section('head')

@show


<h1>All Users</h1>

<p>{{ link_to_route('users.create', 'Add new user') }}</p>

@if ($users->count())
<table class="table table-striped table-bordered">
    <thead>
        <tr>
            <th>Username</th>
    <th>Password</th>
    <th>Email</th>
    <th>Phone</th>
    <th>Name</th>
        </tr>
    </thead>

    <tbody>
        @foreach ($users as $user)
            <tr>
                <td>{{ $user->username }}</td>
      <td>{{ $user->password }}</td>
      <td>{{ $user->email }}</td>
      <td>{{ $user->phone }}</td>
      <td>{{ $user->name }}</td>
                <td>{{ link_to_route('users.edit', 'Edit',
 array($user->id), array('class' => 'btn btn-info')) }}</td>
                <td>
      {{ Form::open(array('method' 
 => 'DELETE', 'route' => array('users.destroy', $user->id))) }}                       
                        {{ Form::submit('Delete', array('class'
 => 'btn btn-danger')) }}
                    {{ Form::close() }}
                </td>
            </tr>
        @endforeach

    </tbody>

</table>
@else
  There are no users
@endif
@show 

当我覆盖它时,它无效。哪条线是错误的?

0 个答案:

没有答案