laravel - Laravel 通过 href 发送数据
问题描述
我需要将表格行的 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>
推荐阅读
- laravel - Laravel - 验证正确的格式
- python - 如何在 virtualenv 中安装 Python 3.6.x?
- python - 如何手动创建熊猫数据框
- node.js - express.js 中嵌套异步函数中的错误处理
- jquery - 按热键跳过 li 不工作 jquery
- go - Golang 加密消息修复 go-crypt()
- c++ - 在 Visual Studio 中编译我的 Visual C++ 文件后,会创建一个 3D 对象文件而不是对象文件
- r - 当我在 R 中使用 Pipe 时,这个错误是什么
- php - codeigniter中数据库中2个表的下拉列表
- python - 当出现错误时,如何设置我的 django debug=False 并在网络上显示 404?