Advertisement
gpressutto5

getAvatarAttribute($value)

Jan 20th, 2017
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.46 KB | None | 0 0
  1.     public function getAvatarAttribute($value)
  2.     {
  3.         $email = $this->email;
  4.         $size = 250;
  5.         $fallback = "https://api.adorable.io/avatars/$size/$email";
  6.         $path = "/uploads/avatars/";
  7.  
  8.         if ($value == null || !file_exists(public_path($path.$value))) {
  9.             return 'https://www.gravatar.com/avatar/'.md5($email).'?s='.$size.'&d='.urlencode($fallback);
  10.         } else {
  11.             return $path.$value;
  12.         }
  13.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement