2015-11-08 165 views
0

控制器類作者語法錯誤,意外 '中'(T_STRING)Laravel 5

public $restful=true; 
    public function index() 
    { 
     $author = Author::all(); 
     return \View::make('authors.index', ['authors' => $author]); 
    } 

爲作者作者

@extends('layouts.default') 
    @section('content') 
     <h1>THIS IS AUTHOR'S PAGE</h1> 

     <ul> 
      @foreach($authors in $author) 
       <li>{{ $author->name }}</li> 
      @endforeach 
     </ul> 
    @endsection 

顯示頁面

class Author extends Model 
{ 
    protected $table = 'authors'; 
} 

查看文件Model類作者

<!DOCTYPE html> 
<HTML> 
    <HEAD><TITLE>Testing</TITLE></HEAD> 
    <BODY> 
     @yield('content') 
    </BODY> 
</HTML> 

我收到錯誤響應。

FatalErrorException in 6d4e39a843ef4ce0421f063e7b907f68 line 5: 
syntax error, unexpected 'in' (T_STRING) 

我無法確切地知道這個錯誤是從,因爲它返回一個字符串代碼,我無法interpret.What我能做的到來。謝謝。

回答

2

我覺得應該是as而不是inin沒有意義順序):

@foreach($authors as $author) 
    <li>{{ $author->name }}</li> 
@endforeach 
+1

你給我的日子上色了!!!!!!! –

1

我想你應該更換

@foreach($authors in $author) 

@foreach($author as $authors) 
相關問題