コード例 #1
0
ファイル: User.php プロジェクト: BlazOrazem/laravel-basis
 /**
  * Get avatar
  *
  * @param int  $width  Avatar width
  * @param null $height Avatar height
  *
  * @return \Intervention\Image\Image|null
  */
 public function avatar($width = 100, $height = null)
 {
     $height = $height ?: $width;
     if (!$this->avatar) {
         return;
     }
     return AvatarController::getAvatarImageUrl($this->avatar, $width, $height);
 }
コード例 #2
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 protected function create(array $data)
 {
     $user = User::create(['name' => $data['name'], 'nickname' => $data['nickname'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'avatar' => isset($data['avatar']) ? AvatarController::makeAvatarFromFile($data['avatar']) : null, 'is_verified' => config('login.verification') ? false : true]);
     if (config('login.verification')) {
         $this->mailer->sendEmailVerificationTo($user);
     }
     return $user;
 }
コード例 #3
0
 /**
  * Update user's profile.
  *
  * @param User $user
  * @param Request $request
  * @return User
  */
 public function updateUser(User $user, Request $request)
 {
     if ($request->email != $user->email) {
         $user->email = $request->email;
         $user->token = str_random(30);
         $user->is_verified = false;
     }
     if ($request->avatar) {
         AvatarController::deleteAvatarFile($user->avatar);
         $user->avatar = AvatarController::makeAvatarFromUrl($request->avatar);
     }
     if ($request->password) {
         $user->password = bcrypt($request->password);
     }
     $user->name = $request->name;
     $user->nickname = $request->nickname;
     $user->save();
     return $user;
 }