public function postPlan($planSlug, Request $request, StripeBilling $billing)
 {
     $this->validate($request, ['first_name' => 'required', 'last_name' => 'required', 'password' => 'required', 'password_confirm' => 'required|same:password', 'email' => 'required|email|unique:users', 'phone' => 'required']);
     $plan = MembershipPlan::where('slug', $planSlug)->firstOrFail();
     $planName = ucwords(str_replace('-', ' ', $planSlug));
     if (!in_array($planSlug, ['annual-platinum', 'annual-gold', 'annual-silver', 'lifetime'])) {
         try {
             $charge = $billing->charge(array('amount' => $plan->amount, 'email' => $request->get('email'), 'name' => $request->get('first_name') . ' ' . $request->get('last_name') . ', ' . $planName, 'stripe-token' => $request->get('stripe-token'), 'plan' => $planSlug));
             $customer = true;
         } catch (\Exception $e) {
             Flash::danger($e->getMessage());
             return redirect()->refresh();
         }
     } else {
         try {
             $charge = $billing->oneTime(array('amount' => $plan->amount, 'name' => $request->get('first_name') . ' ' . $request->get('last_name') . ', ' . $planName, 'stripe-token' => $request->get('stripe-token')));
             $customer = false;
         } catch (\Exception $e) {
             Flash::danger($e->getMessage());
             return redirect()->refresh();
         }
     }
     if (!empty($charge['created'])) {
         $user = User::create(['plan_id' => $plan->id, 'first_name' => $request->get('first_name'), 'last_name' => $request->get('last_name'), 'email' => $request->get('email'), 'phone_number' => $request->get('phone'), 'street_address' => $request->get('address1') . ' ' . $request->get('address2'), 'city' => $request->get('city'), 'state' => $request->get('state_province'), 'zip' => $request->get('postal_code'), 'password' => Hash::make($request->get('password')), 'membership_expires' => $customer ? date('Y-m-d', strtotime('+1 year')) : null, 'customer_id' => $charge['id']]);
         if ($request->get('sms')) {
             Sms::create(['phone_number' => $request->get('phone')]);
         }
         if ($request->get('newsletter')) {
             try {
                 $mailchimp = new Mailchimp(env('MAILCHIMP_API_KEY'));
                 $mailchimp->lists->subscribe(env('MAILCHIMP_LIST_ID'), ['email' => $request->get('email')], null, 'html');
             } catch (Mailchimp_List_AlreadySubscribed $e) {
                 Flash::danger($e->getMessage());
                 return back();
             } catch (\Exception $e) {
                 Flash::danger($e->getMessage());
                 return back();
             }
         }
         Flash::success('Congratulations! You are now a Lambda Phoenix Center ' . $planName . ' member.');
         Auth::login($user);
         return redirect('dashboard/incentives/' . $planSlug);
     }
 }
 public function subscribe(Request $request)
 {
     $this->validate($request, ['phone_number' => 'required']);
     Sms::create(['phone_number' => $request->get('phone_number')]);
     $client = new Services_Twilio(env('TWILIO_SID'), env('TWILIO_AUTH'));
     try {
         $sms = $client->account->messages->sendMessage('508-9-LAMBDA', $request->get('phone_number'), 'Thank you for subscribing to Lambda SMS at 508-9-LAMBDA. We\'ll keep you up to date. Text STOP to unsubscribe.');
         Flash::success('You have been successfully subscribed');
         return back();
     } catch (Services_Twilio_RestException $e) {
         Flash::danger($e->getMessage());
         return back();
     }
 }