0

I need to send the id of the table row to the controllers show function.

Below is my function:

            <tbody>   
            @foreach($invoices as $invoice)             
            <tr>
                <th scope="row">{{ $invoice->total_subcriptions }}</th>
                <td>{{ $invoice->description }}</td>
                <td>{{ $invoice->product_id }}</td>
                <td>Rs.{{ $invoice->total }}</td>
                <td>Not Paid</td>                    
                <th><a href="{{ url('/invoice/(ID here)') }}" class="btn btn-sm btn-info">View</a></th>
            </tr>
            @endforeach
            </tbody>    

How can I send it directly?

This didnt work for me and showed a syntax error:

Exception message: Parse error: syntax error, unexpected '}', expecting ',' or ')'

<th><a href="{{ url('/invoice/{{$invoice->id}}') }}" class="btn btn-sm btn-info">View</a></th>
2
  • What is the error you are getting? Commented Oct 15, 2018 at 9:30
  • The error im getting is: Exception message: Parse error: syntax error, unexpected '}', expecting ',' or ')' Commented Oct 15, 2018 at 9:30

2 Answers 2

1

Looks like you need to concat your url string.

<th><a href="{{ url('/invoice/{{$invoice->id}}') }}" class="btn btn-sm btn-info">View</a></th>

should be

<th><a href="{{ url('/invoice/'.$invoice->id) }}" class="btn btn-sm btn-info">View</a></th>
Sign up to request clarification or add additional context in comments.

Comments

0

Change this

<th><a href="{{ url('/invoice/{{$invoice->id}}') }}" class="btn btn-sm btn-info">View</a></th>

to

<th><a href="{{ url('/invoice/'{{$invoice->id}}) }}" class="btn btn-sm btn-info">View</a></th>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.