Simple transformer to get a gravatar url on a User model
88
0
3
Package Data
Maintainer Username: dionbosschieter
Maintainer Contact: dionbosschieter@gmail.com (dionbosschieter)
Package Create Date: 2015-07-10
Package Last Update: 2015-11-15
Home Page:
Language: PHP
License: MIT
Last Refreshed: 2024-11-21 03:00:42
Package Statistics
Total Downloads: 88
Monthly Downloads: 2
Daily Downloads: 0
Total Stars: 0
Total Watchers: 3
Total Forks: 0
Total Open Issues: 0

Gravatar

Install Gravatar using composer: composer require dionbosschieter/gravatar

Implement the avataruserinterface on your users model use Gravatar\UserGravatarInterface

The gravatar class expects a getEmailAdres method on your user model

<?php

use Gravatar\UserGravatarInterface;

class User extends Model  
{
  
  public function getEmailAdres()
  {
      return $this->email;
  }
}

##Usage

$avatar = new \Gravatar\Gravatar($usermodel);
$avatar->getImageUrl();
$avatar->getImageUrlForSize();

Register the class using your frameworks dependency container:

// Laravel
App::bind('gravatar', function()
{
    $grav = new \Gravatar\Gravatar(app('auth')->user());

    return $grav;
});