/**
  * The member has left, disable their account and cancel any out stand sub charge records
  * The payment day is also cleared so when they start again the payment is charge happens at restart time
  *
  * @param $userId
  */
 public function memberLeft($userId)
 {
     $user = $this->getById($userId);
     $user->active = false;
     $user->status = 'left';
     $user->payment_day = '';
     $user->save();
     $this->subscriptionChargeRepository->cancelOutstandingCharges($userId);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Illuminate\Http\RedirectResponse
  */
 public function destroy($userId, $id = null)
 {
     /**
      * TODO: Check for and cancel pending sub charges
      */
     $user = User::findWithPermission($userId);
     if ($user->payment_method == 'gocardless') {
         try {
             $subscription = $this->goCardless->cancelSubscription($user->subscription_id);
             if ($subscription->status == 'cancelled') {
                 $user->cancelSubscription();
                 \Notification::success('Your subscription has been cancelled');
                 return \Redirect::back();
             }
         } catch (\GoCardless_ApiException $e) {
             if ($e->getCode() == 404) {
                 $user->cancelSubscription();
                 \Notification::success('Your subscription has been cancelled');
                 return \Redirect::back();
             }
         }
     } elseif ($user->payment_method == 'gocardless-variable') {
         $status = $this->goCardless->cancelPreAuth($user->subscription_id);
         if ($status) {
             $user->subscription_id = null;
             $user->payment_method = '';
             $user->save();
             $user->setLeaving();
             $this->subscriptionChargeRepository->cancelOutstandingCharges($userId);
             \Notification::success('Your direct debit has been cancelled');
             return \Redirect::back();
         }
     }
     \Notification::error('Sorry, we were unable to cancel your subscription, please get in contact');
     return \Redirect::back();
 }