laravel解析视图错误

时间:2016-11-19 16:35:27

标签: php laravel

我收到Parse错误:语法错误,意外' - >' (T_OBJECT_OPERATOR),在我的视图文件中期待','或')'。这是我的控制者:

public function gclogs()
    {
      $gclogs = DB::table('duplicategcs')->orderBy('created_at', 'desc')->paginate(20);
        return view('admin.gclogs')->with('gclogs',$gclogs);

    }

这只是视图中的一个片段:

@foreach($gclogs as $gclog)
                            <tr>
                              <td>
                                {{gclog->id}}
                              </td>
                              <td>
                                {{gclog->user_id}}
                              </td>
                              <td>
                                {{gclog->google_id}}
                              </td>
                              <td>
                                {{gclog->google_email}}
                              </td>
                              <td>
                                {{gclog->created_at}}
                              </td>
                              <td>
                                <a href="{{url('admin/users/')}}/{{gclog->user_id}}">User Edit</a>
                              </td>
                            </tr>

                            @endforeach
                              </tbody>
                            </table>
                            <div align="center">
                              {{ $gclogs->render() }}
                            </div>

1 个答案:

答案 0 :(得分:1)

你忘了在foreach中使用$

试试这个:

@foreach($gclogs as $gclog)
<tr>
  <td>
    {{$gclog->id}}
  </td>
  <td>
    {{$gclog->user_id}}
  </td>
  <td>
    {{$gclog->google_id}}
  </td>
  <td>
    {{$gclog->google_email}}
  </td>
  <td>
    {{$gclog->created_at}}
  </td>
  <td>
    <a href="{{url('admin/users/')}}/{{$gclog->user_id}}">User Edit</a>
  </td>
</tr>

@endforeach
  </tbody>
</table>
<div align="center">
  {{ $gclogs->render() }}
</div>