1. Go to this page and download the library: Download forxer/laravel-gravatar library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use App\Models\User;
use LaravelGravatar\Gravatar as Gravatar;
class UserController
{
public function show(User $user, Gravatar $gravatar)
{
$avatar = $gravatar->avatar($user->email);
$profile = $gravatar->profile($user->email);
}
}
// pass it as argument of the helper
$gravatarImage = gravatar($email);
// or use the `setEmail()` method
$gravatarImage = gravatar();
$gravatarImage->setEmail($email);
// or the `email()` helper method
$gravatarImage = gravatar();
$gravatarImage->email($email);
// use the `setSize()` method
$gravatarImage = gravatar($email);
$gravatarImage->setSize(120);
// or the `size()` helper method
$gravatarImage = gravatar($email);
$gravatarImage->size(120);
// or its alias `s()` (as in the generated query string)
$gravatarImage = gravatar($email);
$gravatarImage->s(120);
// use the `setDefaultImage()` method
$gravatarImage = gravatar($email);
$gravatarImage->setDefaultImage('mp');
// or the `defaultImage()` helper method
$gravatarImage = gravatar($email);
$gravatarImage->defaultImage('mp');
// or its alias `d()` (as in the generated query string)
$gravatarImage = gravatar($email);
$gravatarImage->d('mp');
// use the `setMaxRating()` method
$gravatarImage = gravatar($email);
$gravatarImage->setMaxRating('g');
// or the `maxRating()` helper method
$gravatarImage = gravatar($email);
$gravatarImage->maxRating('g');
// or its alias `r()` (as in the generated query string)
$gravatarImage = gravatar($email);
$gravatarImage->r('g');
// use the `setExtension()` method
$gravatarImage = gravatar($email);
$gravatarImage->setExtension('jpg');
// or the `extension()` helper method
$gravatarImage = gravatar($email);
$gravatarImage->extension('jpg');
// or its alias `e()` (as in the generated query string)
$gravatarImage = gravatar($email);
$gravatarImage->e('jpg');
// use the `setForceDefault()` method
$gravatarImage = gravatar($email);
$gravatarImage->setForceDefault(true);
// or the `forceDefault()` helper method
$gravatarImage = gravatar($email);
$gravatarImage->forceDefault(true);
// or its alias `f()` (as in the generated query string)
$gravatarImage = gravatar($email);
$gravatarImage->f(true);
// or use the `enableForceDefault()` method
$gravatarImage = gravatar($email);
$gravatarImage->setForceDefault(true);
// use the `setPreset()` method
$gravatarImage = gravatar($email);
$gravatarImage->setPreset('small');
// or the `preset()` helper method
$gravatarImage = gravatar($email);
$gravatarImage->preset('small');
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use LaravelGravatar\Casts\GravatarImage;
class User extends Model
{
protected $casts = [
'gravatar' => GravatarImage::class,
];
}
use App\Models\User;
class UserController
{
public function show(User $user)
{
$user->gravatar->preset('small');
return view('users.show', [
'user' => $user,
]);
}
}
use LaravelGravatar\Casts\GravatarImage;
class Post extends Model
{
protected $casts = [
'gravatar' => GravatarImage::class.':small',
];
}
use LaravelGravatar\Casts\GravatarProfile;
class User extends Model
{
protected $casts = [
'gravatar' => GravatarProfile::class,
];
}
sh
php artisan vendor:publish --tag="gravatar-config"
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.