我是Laravel的新手,我找不到自己的错误。我确定这是愚蠢的,但错误信息并不是非常明确的,我没有在网上发现类似的错误。
我有这个Blade模板:
@extends('basicTemplateInside')
@section('title')
ABC
@endsection
@section('content')
<table class="table table-striped">
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
@foreach ($lines as $line)
<tr>
<td> {{ $line->name }} </td>
<td> {{ $line->creationTimeStamp }} </td>
<td></td>
<td><span class="glyphicon glyphicon-pencil"></span></td>
<td><span class="glyphicon glyphicon-remove"></span></td>
</tr>
@endforeach
</tbody>
</table>
@endsection
它在第19行[@foreach($ lines as $ line)]中给出了这个错误:
Whoops, looks like something went wrong.
FatalErrorException in 79b7933d82e3f98a55e82cb71b63543f97265b8b.php line 19: parse error
1. in 79b7933d82e3f98a55e82cb71b63543f97265b8b.php line 19
如果您认为问题可能出在控制器中,请输入以下代码:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\CableType;
class CableTypesContoller extends Controller
{
public function show(){
$cableTypes = CableType::all();
//$data = array('lines'=>$cableTypes,'title'=>'Cable Types');
//return view('insideTable5wDelSee')->with($data);
return view('insideTable5wDelSee')->with('lines',$cableTypes);
}
}
编译文件79b7933d82e3f98a55e82cb71b63543f97265b8b.php:
<?php $__env->startSection('title'); ?>
ABC
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
<table class="table table-striped">
<thead>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach($lines as $line): ?>
<tr>
<td> <?php echo e( $line->name); ?> </td>
<td> <?php echo e($line->creationTimeStamp); ?> </td>
<td></td>
<td><span class="glyphicon glyphicon-pencil"></span></td>
<td><span class="glyphicon glyphicon-remove"></span></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('basicTemplateInside', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
和basicTemplateInside.blade.php:
@extends('basicTemplate')
@section('body')
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"> ****** </a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li role="separator" class="divider"></li>
<li class="dropdown-header">Nav header</li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</nav>
<div class="content" style="margin-top: 5%;">
<div class="col-md-10 col-md-offset-1">
<div class="row">
<h1>@yield('title')</h1>
</div>
<div class="row">
@yield('content')
</div>
</div>
</div>
@endsection
和basicTemplate.blade.php(如果你之前需要一个,你也可能需要这个):
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>****** - @yield('pageTitle')</title>
<link href="{{ URL::asset('css/bootstrap.min.css')}}" rel="stylesheet" >
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
@yield('body')
<script src="{{ URL::asset('js/jQuery.js')}}"></script>
<script src="{{ URL::asset('js/bootstrap.min.js')}}"></script>
</body>
</html>
感谢您的时间。