问题:将我的Laravel 4代码转换为Laravel 5.屏幕上没有显示@section(' container')& @stop。
注意:我使用的是Laravel Collective HTML Facades。为简洁起见,我严重缩短了master.blade.php文件。
请求:请帮助弄清楚为什么浏览器中没有显示任何内容,如果可能的话,让我详细了解我的错误示例。
错误&调试:没有。该页面只是空白。
尝试:如果我在@section之外添加任何内容('容器')& @stop然后它出现在屏幕上。
composer.json
"require": {
"php": ">=5.5.9",
"laravelcollective/html": "5.2.*"
},
app.php
Providers Array
Collective\Html\HtmlServiceProvider::class,
Alias Array
'Form' => Collective\Html\FormFacade::class,
'Html' => Collective\Html\HtmlFacade::class,
master.blade.php
<body>
<!--[if lt IE 7]>
<p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
<![endif]-->
<!-- Add your site or application content here -->
@yield('container')
</body>
index.blade.php
@section('container')
<!--[if gte IE 9]>
<style type="text/css">
.gradient {
filter: none;
}
</style>
<![endif]-->
<div style="margin: 10px 0 0 20px;border: 0px black dashed;width: 410px;float:left;">
{!! Form::open(array('action' => 'ContractController@store')) !!}
{!! Form::token() !!}
<dl style="list-style-type:none;">
<fieldset>
<legend>General Information</legend>
<dd>
{!! Form::label('contractterm','Contract Term', array('class' => 'label')) !!}
{!! Form::select('contractterm_id', $contracttermlist) !!}
</dd>
<dd>
{!! Form::label('businesstype','Business Type', array('class' => 'label')) !!}
{!! Form::select('businesstype_id', $businesstypelist) !!}
</dd>
<dd>
{!! Form::label('contract_date','Contract Starting Date', array('class' => 'label')) !!}
{!! Form::text('contract_date', date('m/d/Y'), array(
'size'=>'16',
'id' =>'datepicker'))
!!}
</dd>
<dd>
{!! Form::label('service_credit','Previous Service', array('class' => 'label')) !!}
<div style="float:right;width:140px;height:29px;"><span>Yes</span><span style="float:right;width:20px;padding-top:4px;padding-right:90px;">{!! Form::checkbox('prevcredit', 'credityes', false, array('class' => 'creditcheckbox','id' => 'prevcredit')); !!}</span></div>
</dd>
<dd>
{!! Form::label('credit_amount','Credit Amount', array('class' => 'label','id' => 'credit_amount')) !!}
{!! Form::text('credit_amount','0.00',array('id' => 'credit_amount2')) !!}
</dd>
<dd>
{!! Form::label('addtpcs','Additional PCs', array('class' => 'label')) !!}
{!! Form::select('addtpcs', $addtpcs) !!}
</dd>
<div id="inputs" style="margin:0;">
</div>
</fieldset>
<fieldset>
<legend>Personal Information</legend>
<dd>
{!! Form::label('firstname','First Name', array('class' => 'label')) !!}
{!! Form::text('firstname') !!}
</dd>
<dd>
{!! Form::label('lastname','Last Name', array('class' => 'label')) !!}
{!! Form::text('lastname') !!}
</dd>
<dd>
{!! Form::label('hstraddr','Home Address', array('class' => 'label')) !!}
{!! Form::text('hstraddr') !!}
</dd>
<dd>
{!! Form::label('hcity','Home City', array('class' => 'label')) !!}
{!! Form::text('hcity') !!}
</dd>
<dd>
{!! Form::label('hstate','Home State', array('class' => 'label')) !!}
{!! Form::text('hstate', 'Florida') !!}
</dd>
<dd>
{!! Form::label('hzip','Home Zip Code', array('class' => 'label')) !!}
{!! Form::text('hzip') !!}
</dd>
<dd>
{!! Form::label('hphone','Home Phone', array('class' => 'label')) !!}
{!! Form::text('hphone') !!}
</dd>
<dd>
{!! Form::label('mobile','Mobile Phone', array('class' => 'label')) !!}
{!! Form::text('mobile') !!}
</dd>
</fieldset>
<fieldset>
<legend>Business Information</legend>
<dd>
{!! Form::label('company','Company Name', array('class' => 'label')) !!}
{!! Form::text('company') !!}
</dd>
<dd>
{!! Form::label('bstraddr','Business Address', array('class' => 'label')) !!}
{!! Form::text('bstraddr') !!}
</dd>
<dd>
{!! Form::label('bcity','Business City', array('class' => 'label')) !!}
{!! Form::text('bcity') !!}
</dd>
<dd>
{!! Form::label('bstate','Business State', array('class' => 'label')) !!}
{!! Form::text('bstate', 'Florida') !!}
</dd>
<dd>
{!! Form::label('bzip','Business Zip', array('class' => 'label')) !!}
{!! Form::text('bzip') !!}
</dd>
<dd>
{!! Form::label('bphone','Business Phone', array('class' => 'label')) !!}
{!! Form::text('bphone') !!}
</dd>
<dd>
<div class="submitbutton">
{!! Form::submit('Submit') !!}
</div>
</dd>
</fieldset>
</dl>
{!! Form::close() !!}
</div>
<div style="clear:both;"></div>
@stop
IndexController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Library\additionalPCs;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use View;
use App\Models\businesstype;
use App\Models\contractterm;
class IndexController extends BaseController
{
Protected $layout = 'master';
/**
* Display a listing of the resource.
*
* @return Response
*/
public function index()
{
/** Wayne - 03-02-2014 - Moved for loop to a method within its own class. */
$numberofpcs = new additionalPCs();
$addtpcs=$numberofpcs->display();
//$this->layout->content = View::make('index')->with('addtpcs', $addtpcs)->with('businesstypelist', businesstype::dropdown())->with('contracttermlist',ContractTerm::dropdown());
return view('index')->with('addtpcs', $addtpcs)->with('businesstypelist', businesstype::dropdown())->with('contracttermlist',ContractTerm::dropdown());
}
}
答案 0 :(得分:2)
现在是@section('container')
,然后是@endsection
,而不是Laravel 5.1中的@stop
。
答案 1 :(得分:2)
在你的index.blade文件中,你似乎缺少应该出现在最顶层的extends标记,后面是你的@section代码
@extends('master')
@section('container')
your section code here
@stop