laravel - 每次我在路由中添加 URL 参数时都缺少 [Route 所需的参数
问题描述
嗨,我的 order.index 中有一个 URL 参数
<a href="/order-payments/create/{{$order->id}}"><i class="fas fa-dollar-sign"></i></a>
我将 id 传递给我的 order-payments.create。但是每次我在路由中添加 {id}
Route::get('/order-payments/create/{id}', 'OrderpaymentsController@create')->name('order-payments.create');
它给了我这个错误
即使在其他页面中,此错误也显示在我的整个页面中。
你认为是什么导致了这个问题?提前致谢!
更新
这是我的商店并在我的 OrderpaymentsController 中创建功能
public function create()
{
return view('order-payments.create', compact('orderpayments'));
}
public function store(Request $request)
{
// $orderpayments = Orderpayments::create($request->only('title'));
// return redirect(route('order-payments.index'));
$order = Orders::all('grandtotal','currency_id','company_id','id');
$company = Companies::all('comp_name','id');
$currency = Currencies::all('name','acronym','id');
$banks = Banks::all('name','acronym','id');
// dd($currency['name']);
return view('order-payments.create', compact('orderpayments'))
->with('currency', $currency)
->with('banks', $banks)
->with('order', $order)
->with('company', $company)
->with('orderId', $order->id);
// return view('order-payments.create');
}
解决方案
尝试这个:
<a href="{{ route('order-payments.create', $order->id) }}"><i class="fas fa-dollar-sign"></i></a>
确保你进入$order->id
刀片文件
OrderpaymentsController.php
public function create($order_id)
{
$orderpayments = OrderPayment::find($order_id); //your query
return view('order-payments.create', compact('orderpayments'));
}
推荐阅读
- node.js - 查询嵌套 mongdb 文档的属性
- c++ - 在 c++ 中使用模板在核心类型不同的不同项目中使用通用代码
- javascript - 变量问题
- apache - 重定向除根域之外的所有目录
- reactjs - 在 Const 中 React Redux Dispatch Action
- javascript - 如何将我的 json 数据转换为字符串数组并显示文本?
- ionic3 - Is there a way to pass parameters when visiting a page using "cy.visit" like when using "navCtrl.push('testpage', params)"?
- openseadragon - Angular 7 中的 OpenSeadragon
- javascript - Vue - 使用子组件进行添加和更新
- php - 在php中使用if语句对数字进行排序