php - Pass variable from one function to another inside a single controller -


i'm trying pass variable within function next function called can error variable isn't defined.

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(); } 

you have pass variable while calling fucntion

return $this->recordorder($package); 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -