2017-10-22 2 views
1

私は意見を持っていると私は、データベースにあるレコードのLaravelビュー:構文エラー、予期しない 'ENDIF'(T_ENDIF)

  • ID
  • ファーストネーム
  • を表示したいと思います
  • 電話

しかし、彼は私に、このエラーを示しています

FatalErrorException 26行6361dda302a0f162671ee5b36a4abe93で: 構文エラー、予期しない 'ENDIF'(T_ENDIF)

welcome.blade.php:

@extends('layouts.master') 

@section('title') 
    Welcom! 
@endsection 

@section('content') 

<div class="container"> 
    <div class="row"> 
     <legend>List</legend> 
     <table class="table table-striped table-hover "> 
      <thead> 
      <tr> 
       <th>ID</th> 
       <th>lastaname</th> 
       <th>firstname</th> 
       <th>phone</th> 
      </tr> 
      </thead> 
      <tbody> 
      @if (count($customers) > 0) 
       @foreach($customers->all() as $customer) 
        <tr> 
         <td>{{ $customer->id }}</td> 
         <td>{{ $customer->lastaname }}</td> 
         <td>{{ $customer->firstname }}</td> 
         <td>{{ $customer->phone }}</td> 
        </tr> 
       @enforeach 
      @endif 
      </tbody> 
     </table>  
    </div> 
</div> 
@endsection 

CreatesController:

<?php namespace App\Http\Controllers; 

use App\Http\Requests; 
use App\Http\Controllers\Controller; 

use Illuminate\Http\Request; 
use App\Customer; 

class CreatesController extends Controller { 

    public function welcome() 
    { 
     $customers = Customer::all(); 
     return view('welcome', ['customers' => $customers]); 
    } 

答えて

4

を使用する必要があります代わり

https://laravel.com/docs/5.5/blade#loops@enforeachのLaravelは、それが例外をスロー理由です、あなたが最初に@foreachを閉じて期待しています。

関連する問題