2016-01-28 4 views
0

Редакция: Преобразование моего кода Laravel 4 в Laravel 5. Ничего не отображается на экране между @section ('container') & @stop.Имеет ли Blade Templating изменено с Laravel 4 до Laravel 5?

Примечания: Я использую 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' => '[email protected]')) !!} 
     {!! 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()); 
    } 
} 

ответ

2

В файле index.blade вы, кажется, не хватает расширений с тег, который должен появиться на самом верху, а затем код @section

@extends('master') 
@section('container') 
    your section code here 
@stop 
+1

Спасибо, Луча. Это решило проблему. Кого читаешь, посмотри на ответ Джеффа. Начиная с Laravel 5.1 остановка была заменена концами. Обновите свой код соответствующим образом. – scrfix

+1

Ах, пропустил это! Хорошая работа Луча – Jeff

2

Это теперь @section('container'), а затем @endsection вместо @stop от Laravel 5.1.

https://laravel.com/docs/5.1/blade#template-inheritance

+0

Благодарим Вас за давая мне знать. Я обновил эту остановку до конца и обновит остальные шаблоны клинков. Это, к сожалению, не решило проблему. Ответ Лучи разрешил проблему с концом или без остановки. – scrfix

Смежные вопросы