Skip to content

remzikocak/laravel-gravatar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gravatar Helper for Laravel 9/10/11/12

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.

About

This Package will help you to Generate Gravatar URL's with Laravel.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages