Sunday, March 5, 2017

Laravel Blade @foreach : parse error

I'm new to Laravel, and I cannot find my mistake. I'm sure it's stupid, but the error message it's not really explicit, and I have not found a similar error on the net.

I have this Blade template:

@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>  </td>
          <td>  </td>
          <td></td>
          <td><span class="glyphicon glyphicon-pencil"></span></td>
          <td><span class="glyphicon glyphicon-remove"></span></td>
        </tr>
      @endforeach
    </tbody>
  </table>
@endsection

and it gives me this error in line 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

If you think the problem might be in the controller, here is the code:

<?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);
    }

}

Thank you for your time.



via Skrime

Advertisement