RaZZeR RaZZeR - 18 days ago 5
PHP Question

laravel Parse error on view

I'm getting Parse error: syntax error, unexpected '->' (T_OBJECT_OPERATOR), expecting ',' or ')' on my view file. This is my controller:

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

}


and this is just a snippet from view:

@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>

Answer

You forget use $ inside foreach.

Try this:

@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>