Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/laravel/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 函数App\Http\Controllers\RaveController::addToOrdersTables()的参数太少,已传递0个,预期正好是2个_Php_Laravel_Laravel 7 - Fatal编程技术网

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

Php 函数App\Http\Controllers\RaveController::addToOrdersTables()的参数太少,已传递0个,预期正好是2个,php,laravel,laravel-7,Php,Laravel,Laravel 7,嗨,我使用RaveWave作为我的支付网关。我想在客户完成付款时存储订单,但我无法通过该错误。我不知道我错过了什么。 谢谢你的帮助,这是我的代码 public function callback(Request $request) { // $data = Rave::verifyTransaction(request()->txref); $resp = $request->resp; $body = json_decode($resp, true

嗨,我使用RaveWave作为我的支付网关。我想在客户完成付款时存储订单,但我无法通过该错误。我不知道我错过了什么。 谢谢你的帮助,这是我的代码

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)

请不要垃圾邮件标签,您使用的是5或7?Am使用的是laravel-7-XY。您需要在通话中键入提示请求,并使用
request$request
。我不知道
$error
是什么,但您需要传入它,从函数调用中取出它并从
$request
获取它,或者找出它应该来自哪里。我还建议重命名路由<代码>成功和
$error
在我看来是矛盾的。它可以是
result/{$status?}
方法定义为
(Request$Request$status)
他也可以使用{error?}将其作为可选参数-我假设不会总是有错误