php - 我需要从带有所选项目 id 的输入中获取值并将它们返回给控制器
问题描述
我是 Laravel 的新手,我正在尝试使用选定元素的 id 获取输入值。
当我试图在控制器中获取数量的输入值时,它实际上是空的。
这是我的代码。
收集刀片.php
@foreach($reagentcard as $r)
<tr>
<td>{{ $i++ }}</td>
<td>{{ $r->casnumber }}</td>
<td>{{ $r->name }}</td>
<td>{{ $r->description }}</td>
<td>{{ $r->classification }}</td>
<td>{{ $r->manname }}</td>
<td>{{ $r->incomedate}} </td>
<td>{{ $r->expirationdate}} </td>
<td>{{ $r->quantity }} </td>
<td><input class="form-control" type="number" name="quantity"></td>
@if($message = Session::get('info'))
<strong style="color:red">{{ $message }}</strong><br>
@endif
@if($message = Session::get('error'))
<strong style="color:red">{{ $message }}</strong><br>
@endif
<td><a href=" {{ route('collect',['id' => $r -> id]) }}"><button> Collect </button></a> </td>
@endforeach
控制器.php
public function collectReagent($id, Request $request)
{
$user_id = Auth::user()->id;
$takedate = Carbon::now();
$reagentcard = ReagentCard::where('id',$id)->first();
$test = $request->route('quantity');
return view('test',compact('test', 'id'));
}
解决方案
推荐阅读
- c# - 在 Xamarin 中运行时使用 ViewCells 填充 ListView
- java - Java中的骆驼案例到句子案例
- python - Python 3.8 无法让 os.chdir() 使用双反斜杠
- maven - 如何在 Github Actions 工作流中从 Github 包访问 Maven 依赖项?
- pandas - 带有 PySpark 2.4 的 Pandas UDF
- google-apps-script - 从另一个工作表粘贴单元格引用
- javascript - 如何在开发中自动删除 console.logs()?
- python - 未安装的软件包在尝试将它们导入 jupyter notebook 时工作
- python - 如何添加库存剩余计数器?
- mysql - pl sql 列名作为参数