Exemplo n.º 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);
     }
 }
 /**
  * 
  * 
  * ...Yeah, it's just an alias of buildGravatarURL.  This is just to make it easier to use as a twig asset.
  *
  * @see \thomaswelton\GravatarLib\Gravatar::buildGravatarURL()
  * @static 
  */
 public static function get($email, $hash_email = true)
 {
     //Method inherited from \thomaswelton\GravatarLib\Gravatar
     return \Thomaswelton\LaravelGravatar\Gravatar::get($email, $hash_email);
 }