我试图将一个函数中的变量传递给下一个被调用的函数,但是我可以错误地说该变量没有定义。
public function postPayment(Request $request) {
//Fetch package name
$package = $request->input('package');
//Record order
return $this->recordOrder()->with('package', $package);
}
public function recordOrder($package){
$stripe_trans = User::where('id', Auth::user()->id)->pluck('stripe_id');
$order = new Orders;
$order->user_id = Auth::user()->id;
$order->order_id = $stripe_trans;
$order->status = 'Pending';
$order->save();
return redirect()->back();
}
答案 0 :(得分:1)
你必须在调用fucntion时传递变量
return $this->recordOrder($package);