예제 #1
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $notify = isset($data['notify']) ? $data['notify'] : 0;
     $user = User::create(['email' => $data['email'], 'password' => bcrypt($data['password']), 'notify' => $notify, 'api_key' => md5($data['email'] . time()), 'requests_starts_at' => date('Y-m-d H:i:s'), 'requests_per_month' => config('app.defaults.requests_per_month'), 'requests_left' => config('app.defaults.requests_per_month')]);
     $this->sendWelcomeEmail($user);
     if ($notify == 1) {
         $this->addUserToUpdates($user);
     }
     return $user;
 }
예제 #2
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $users = User::all();
     foreach ($users as $k => $user) {
         if ($user->requests_starts_at->lte(Carbon::now())) {
             $user->requests_starts_at = $user->requests_starts_at->addMonth();
             $user->requests_left = $user->requests_per_month;
             $user->save();
         }
     }
 }
예제 #3
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $users = User::all();
     foreach ($users as $k => $user) {
         $used = \Cache::get("requests:users:{$user->id}");
         if (!is_null($used) && $used > 0) {
             $user->requests_left -= $used;
             $user->save();
             \Cache::forget("requests:users:{$user->id}");
         }
     }
 }