Exemplo n.º 1
0
 /**
  * @author: lmkhang - skype
  * @date: 2016-01-04
  * Activating User
  */
 public function activate_registration($code)
 {
     //Check isLogged
     if ($this->isLogged()) {
         die;
     }
     $hours = \App\Config::where(['prefix' => 'site', 'name' => 'active_expire', 'del_flg' => 1])->get()[0]['value'];
     $date = date('Y-m-d H:i:s', strtotime("-" . $hours . " hours", time()));
     $code = $code ? $this->trim($code) : '';
     if ($code) {
         $registration_system = config('constant.registration');
         $username = \App\User::select('user_id', 'email', 'registration_system')->whereRaw('registration_system = ? AND status = ? AND del_flg = ? AND active_code = ? AND ? <= DATE_FORMAT(`created_at`, "%Y-%m-%d %T")', [$registration_system['site'], 1, 0, $code, "'" . $date . "'"])->first();
         if ($username) {
             //Check existed email
             $message = $this->checkUserAttributes(['email' => $username->email], $registration_system['site']);
             if (!$message) {
                 //Activate Account
                 $username->del_flg = 1;
                 $username->active_code = '';
                 $username->save();
                 //Update User Stats
                 $user_stats = \App\UserStats::find($username['user_id']);
                 $user_stats->del_flg = 1;
                 $user_stats->save();
                 //Set Session
                 $this->setLogSession(['email' => $username->email, 'user_id' => $username->user_id, 'registration_system' => $username->registration_system]);
                 //set Flash Message
                 $this->setFlash('message', 'Activate successfully!');
                 return Redirect::intended('/')->with('message', 'Activate successfully!');
             }
         }
     }
     //Error..
     //do something
 }
Exemplo n.º 2
0
 /**
  * @author: lmkhang - skype
  * @date: 2016-02-05
  * Get all amount of all user >= min pay
  */
 public function getPayAmount()
 {
     //min PAY
     $minpay = \App\Config::where(['prefix' => 'payment', 'name' => 'minpay', 'del_flg' => 1])->get()[0]['value'];
     return \App\UserStats::whereRaw('status = ? AND del_flg = ? AND total >= ? ', [1, 1, $minpay])->sum('total');
 }