예제 #1
0
 /**
  * Initialize required stuff.
  */
 public function __construct()
 {
     if (Auth::check()) {
         // Check if admin center should be displayed
         $roles = new Roles();
         $showAdminCenter = false;
         if ($roles->getAdminRoleId() === Auth::user()->role_id || $roles->getModeratorRoleId() === Auth::user()->role_id) {
             $showAdminCenter = true;
         }
         View::share(['showAdminCenter' => $showAdminCenter, 'validSubscription' => UserHelper::validSubscription()]);
         // Set language
         App::setLocale(Settings::language());
         // Check if user subscription is expired
         if (UserHelper::subscriptionLeftDays(Auth::user()->id) < 0) {
             UserTrialPeriod::where('user_id', Auth::user()->id)->update(['expired' => true]);
         }
     }
 }
예제 #2
0
파일: UserHelper.php 프로젝트: bitller/nova
 /**
  * Return trial period of given user.
  *
  * @param int|bool $userId Optional. If not given the id of current logged in user will be used.
  * @return array
  *      'validity_days' int Number of validity days.
  *      'start' string Trial start date
  */
 private static function _userTrialPeriodQuery($userId = false)
 {
     if (!$userId) {
         $userId = \Auth::user()->id;
     }
     $userTrial = UserTrialPeriod::where('user_id', $userId)->select('user_trial_periods.created_at as start', 'trial_periods.validity_days as validity_days')->leftJoin('trial_periods', 'user_trial_periods.trial_period_id', '=', 'trial_periods.id')->groupBy('trial_periods.id')->first();
     return $userTrial;
 }