remzikocak / laravel-gravatar
Gravatar Generator for Laravel 9/10
2.1.0
2024-03-10 11:28 UTC
Requires
- php: ^8.1
- illuminate/config: ^9.0|^10.0|^11.0
- illuminate/support: ^9.0|^10.0|^11.0
Requires (Dev)
- phpunit/phpunit: ^9.0
README
This Package will help you to Generate Gravatar URL's with Laravel.
Installation
You can install the package via composer:
composer require remzikocak/laravel-gravatar
Usage
Get Users Gravatar URL:
Gravatar::url('test@example.com');
Get Users Gravatar with Custom Configuration:
Gravatar::for('test@example.com') ->size(150) ->default('identicon') ->rating('x') ->get();
Get HTML Image Tag:
Gravatar::img('test@example.com')
Get HTML Image Tag with attributes:
Gravatar::img('test@example.com', [ 'class' => 'w-10 h-10 rounded-full' ])
Check if Gravatar for an email exists:
Gravatar::exists('test@example.com')
Get Gravatar using 'HasGravatar' trait:
First add 'HasGravatar' trait to your User Model.
<?php namespace App; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Notifications\Notifiable; use RKocak\Gravatar\Traits\HasGravatar; class User extends Authenticatable { use Notifiable, HasGravatar;
after adding the Trait, you can use it like this
$user = App\User::find(1); // This will return the Gravatar URL $user->getGravatar(); // or get the Generator instance with preset email $generator = $user->getGravatarGenerator();
License
The MIT License (MIT). Please see License File for more information.