Exemplo n.º 1
0
 /**
  * getTrialEndDate
  * --------------------------------------------------
  * Returns the trial period ending date
  * @return (date) ($trialEndDate) The ending date
  * --------------------------------------------------
  */
 public function getTrialEndDate()
 {
     /* Return the date */
     return Carbon::instance($this->created_at)->addDays(SiteConstants::getTrialPeriodInDays());
 }
 /**
  * createUser
  * creates a new User object (and related models)
  * from the POST data
  * --------------------------------------------------
  * @param (array) ($userdata) Array with the user data
  * @return (User) ($user) The new User object
  * --------------------------------------------------
  */
 private function createUser($userdata)
 {
     /* Create new user */
     $user = new User();
     /* Set authentication info */
     $user->email = $userdata['email'];
     $user->password = Hash::make($userdata['password']);
     $user->name = $userdata['name'];
     /* Save the user */
     $user->save();
     /* Create default settings for the user */
     $settings = new Settings();
     $settings->user()->associate($user);
     $settings->newsletter_frequency = 0;
     $settings->background_enabled = true;
     /* Save settings */
     $settings->save();
     /* Create default subscription for the user */
     $plan = Plan::where('name', 'Free')->first();
     $subscription = new Subscription();
     $subscription->user()->associate($user);
     $subscription->plan()->associate($plan);
     $subscription->status = 'active';
     $subscription->current_period_start = Carbon::now();
     $subscription->current_period_end = Carbon::now()->addDays(SiteConstants::getTrialPeriodInDays());
     $subscription->braintree_customer_id = null;
     $subscription->braintree_payment_method_token = null;
     /* Save subscription */
     $subscription->save();
     /* Return */
     return $user;
 }