Laravel 通过 href 发送数据
Laravel send data through href
我需要将 table 行的 ID 发送到控制器显示功能。
下面是我的函数:
<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>
如何直接发送?
这对我不起作用并显示语法错误:
异常消息:分析错误:语法错误,意外的“}”,应为“,”或“)”
<th><a href="{{ url('/invoice/{{$invoice->id}}') }}" class="btn btn-sm btn-info">View</a></th>
看来您需要连接 url 字符串。
<th><a href="{{ url('/invoice/{{$invoice->id}}') }}" class="btn btn-sm btn-info">View</a></th>
应该是
<th><a href="{{ url('/invoice/'.$invoice->id) }}" class="btn btn-sm btn-info">View</a></th>
改变这个
<th><a href="{{ url('/invoice/{{$invoice->id}}') }}" class="btn btn-sm btn-info">View</a></th>
至
<th><a href="{{ url('/invoice/'{{$invoice->id}}) }}" class="btn btn-sm btn-info">View</a></th>
我需要将 table 行的 ID 发送到控制器显示功能。
下面是我的函数:
<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>
如何直接发送?
这对我不起作用并显示语法错误:
异常消息:分析错误:语法错误,意外的“}”,应为“,”或“)”
<th><a href="{{ url('/invoice/{{$invoice->id}}') }}" class="btn btn-sm btn-info">View</a></th>
看来您需要连接 url 字符串。
<th><a href="{{ url('/invoice/{{$invoice->id}}') }}" class="btn btn-sm btn-info">View</a></th>
应该是
<th><a href="{{ url('/invoice/'.$invoice->id) }}" class="btn btn-sm btn-info">View</a></th>
改变这个
<th><a href="{{ url('/invoice/{{$invoice->id}}') }}" class="btn btn-sm btn-info">View</a></th>
至
<th><a href="{{ url('/invoice/'{{$invoice->id}}) }}" class="btn btn-sm btn-info">View</a></th>