コード例 #1
0
 /**
  * @param Gravatar $gravatar
  * @param Filesystem $files
  * @param AccountManager $manager
  * @throws \Exception
  */
 public function handle(Gravatar $gravatar, Filesystem $files, AccountManager $manager)
 {
     if ($gravatar->exists($this->user->email)) {
         $gravatar->setAvatarSize(512);
         $url = $gravatar->get($this->user->email);
         $content = file_get_contents($url);
         $tmpDir = storage_path('media' . '/' . $this->user->getMediaFolder());
         if (!$files->isDirectory($tmpDir)) {
             $files->makeDirectory($tmpDir, 0755, true);
         }
         $path = $tmpDir . sha1(time() . 'user-profile-pic' . $this->user->id);
         $files->put($path, $content);
         $finalPath = $this->pathWithExtension($path);
         $files->move($path, $finalPath);
         $this->dispatch(new StoreNewImage($manager->account(), $this->user, $finalPath));
         $files->delete($finalPath);
     }
 }
コード例 #2
0
 /**
  * Check if a Gravatar image exists.
  *
  * @param string $email The email address.
  * @return bool True if the Gravatar exists, false otherwise.
  * @static 
  */
 public static function exists($email)
 {
     return \Thomaswelton\LaravelGravatar\Gravatar::exists($email);
 }