函数 App\Http\Controllers\RaveController::addToOrdersTables() 的参数太少,传递了 0 个,预期正好是 2 个

Too few arguments to function App\Http\Controllers\RaveController::addToOrdersTables(), 0 passed and exactly 2 expected

您好,我正在使用 RaveFlutterWave 作为我的支付网关。我想在客户完成付款时存储订单,但我无法通过该错误。我不知道那里缺少什么。 感谢您的帮助,这是我的代码。

public function callback(Request  $request)
  {

    // $data = Rave::verifyTransaction(request()->txref);

    $resp = $request->resp;
    $body = json_decode($resp, true);
    $txRef = $body['data']['data']['txRef'];
    $data = Rave::verifyTransaction($txRef);
    
    return redirect()->route('success');
    

  }

这是我的路线

Route::get('/success', 'RaveController@addToOrdersTables')->name('success');

这是我保存订单的方法

protected function addToOrdersTables($request, $error)
  { 
    $order = Order::create([
        'user_id' => auth()->user() ? auth()->user()->id : null,
        'billing_email' => $request->email,
        'billing_first_name' => $request->first_name,
        'billing_last_name' => $request->last_name,
        'billing_address' => $request->address,
        'billing_city' => $request->city,
        'billing_town' => $request->town,
        'billing_postalcode' => $request->postalcode,
        'billing_phone' => $request->phone,
        'billing_total' => Cart::getTotal(),
        'error' => $error,
  
      ]);
  
      foreach (Cart::getContent() as $item) 
        {
          
          OrderProduct::create([
            'order_id' => $order->id,
            'product_id' => $item->model->id,
            'quantity' => $item->quantity,
          ]);
        }
  }

谢谢关心

你也必须通过路由传递参数:

Route::get('/success/{error}', 'RaveController@addToOrdersTables')->name('success');

并且在 addToOrdersTables 方法类型中提示使用 Request 的请求,如下所示:

protected function addToOrdersTables(Request $request, $error)