Syntax error, unexpected ')', expecting ';' or ',' I am outputting a foreach loop using the compact variable from my Products Controller in a blade file but it keeps coming up with an error in the view that doesn't make sense.
'''
@foreach($products as $product)
<tr>
<td style="width:50px; border: 1px solid #333;"><img class="card-img-top img-fluid" src="{{url('images',$product->image)}}" width="50px" alt="Card image cap"></td>
<td style="width:50px;">{{$product->id}}</td>
<td style="width:50px;">{{$product->product_name)}}</td>
<td style="width:50px;">{{$product->product_code}}</td>
<td style="width:50px;">{{$product->product_price}}</td>
<td style="width:50px;">{{$product->category_id}}</td>
<td><a href="{{route('ProductEditForm',$product->id)}}" class="btn btn-success btn-small">Edit</a></td>
{!! Form::open(['method' => 'DELETE' 'action' => ['ProductsController@destroy', $product->id]]) !!}
<td>{!! Form::submit('Delete Product', ['class' => 'btn btn-danger col-sm-6']) !!}</td>
{!! Form::close() !!}
</tr>
@endforeach
'''
The error appears on the line with the image in although I'm not sure why. Not sure whether this is related to the view or controller?
This could be due to some blade not terminated correctly earlier in the page
{!! Form::open(['method' => 'DELETE', 'action' => ['ProductsController@destroy', $product->id]]) !!}
Didn't even notice the error with that, fixed that now but the same error remains for the page.
Here is the full blade file:
@extends('admin.master')
@section('content')
<main class="col-sm-9 ml-sm-auto col-md-10 pt-3" role="main">
<h3>Products</h3>
<ul>
<!-- INVERSE/DARK TABLE -->
<table class="table table-dark">
<thead>
<tr>
<th>Image</th>
<th>Product Id</th>
<th>Product Name</th>
<th>Product Code</th>
<th>Product Price</th>
<th>Category Id</th>
<th>Update</th>
</tr>
</thead>
<tbody>
@foreach($products as $product)
<tr>
<td style="width:50px; border: 1px solid #333;"><img class="card-img-top img-fluid" src="{{url('images',$product->image)}}" width="50px" alt="Card image cap"></td>
<td style="width:50px;">{{$product->id}}</td>
<td style="width:50px;">{{$product->product_name)}}</td>
<td style="width:50px;">{{$product->product_code}}</td>
<td style="width:50px;">{{$product->product_price}}</td>
<td style="width:50px;">{{$product->category_id}}</td>
<td><a href="{{route('ProductEditForm',$product->id)}}" class="btn btn-success btn-small">Edit</a></td>
{!! Form::open(['method' => 'DELETE', 'action' => ['ProductsController@destroy', $product->id]]) !!}
<td>{!! Form::submit('Delete Product', ['class' => 'btn btn-danger col-sm-6']) !!}</td>
{!! Form::close() !!}
</tr>
@endforeach
</tbody>
</table>
</main>
@endsection
Please format your code by putting 3 backticks ``` on a line before and after each code block
How do I edit the existing post with the code in to do this. I can't find an edit feature that lets me change it to include the backticks.
when you hover over your post, three dots appear at the bottom. hover over these and an edit option appears.
Other pages that extend admin.master work ok?
Yeah checked all the pages and they work fine other than this one.
does the full error give any more clues ?
If using Laravel 7, you can share the error
Not really, it's on the image section in the table and I can't understand why. And Yes I've just shared the error.
Not sure whether this could be connected to the Products Controller although I can't anything wrong with it in there.
Yes I've just shared the error.
?
Please sign in or create an account to participate in this conversation.