public function changeSubscriptionPlan(Request $request)
    {
        $this->validate($request, [
            'plan' => 'required',
        ]);

        $plan = Spark::plans()->find($request->plan);

        if ($plan->price() === 0) {
            $this->cancelSubscription();
        } else {
            Auth::user()->subscription($request->plan)
                    ->maintainTrial()->prorate()->swapAndInvoice();
        }

        event(new SubscriptionPlanChanged(Auth::user()));

        return $this->users->getCurrentUser();
    }
public function changeSubscriptionPlan(Request $request)
    {
        $this->validate($request, [
            'plan' => 'required',
        ]);

        $plan = Spark::plans()->find($request->plan);

        if ($plan->price() === 0) {
            $this->cancelSubscription();
        } else {
            Auth::user()->subscription($request->plan)
                    ->maintainTrial()->prorate()->swapAndInvoice();
        }

        event(new SubscriptionPlanChanged(Auth::user()));

        return $this->users->getCurrentUser();
    }
public function changeSubscriptionPlan ( Request $ request ) { $ this -> validate ( $ request , [ 'plan' => 'required' , ] ) ; $ plan = Spark :: plans ( ) -> find ( $ request -> plan ) ; if ( $ plan -> price ( ) === 0 ) { $ this -> cancelSubscription ( ) ; } else { Auth :: user ( ) -> subscription ( $ request -> plan ) -> maintainTrial ( ) -> prorate ( ) -> swapAndInvoice ( ) ; } event ( new SubscriptionPlanChanged ( Auth :: user ( ) ) ) ; return $ this -> users -> getCurrentUser ( ) ; }
Change the user's subscription plan.

@param  \Illuminate\Http\Request  $request
@return \Illuminate\Http\Response
Change the user s subscription plan .