示例#1
0
 /**
  * Handle the event.
  *
  * @param  NewUser $event
  *
  * @return void
  */
 public function handle(NewUser $event)
 {
     $user = $event->user;
     // Give user an avatar
     $image = AdorableAvatars::getImage($user->id);
     $user->imageId = $image->id;
     $user->save();
     EventLog::create(['type' => EventLog::TYPE_NEW_USER, 'userId' => $user->id]);
 }
 /**
  * @api            {post} /users/:username/generate-avatar Generate A New Avatar
  * @apiGroup       Users
  * @apiDescription Remove the user's existing avatar and generate a new automatic one.
  * @apiUse         RequiresAuthentication
  *
  * @param  User $user
  *
  * @return Response
  */
 public function generateAvatar(User $user)
 {
     $this->requireUser($user);
     $image = AdorableAvatars::getImage($user->id);
     $user->imageId = $image->id;
     $user->save();
     return $this->response(['user' => $user->fresh(), 'success' => true]);
 }
示例#3
0
 /**
  * @return Image|bool
  */
 public function ensureHasAvatar()
 {
     if (!$this->imageId) {
         $image = AdorableAvatars::getImage($this->id);
         $this->imageId = $image->id;
         return $image;
     }
     return true;
 }