Download the PHP package martian/laravatar without Composer
On this page you can find all versions of the php package martian/laravatar. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download martian/laravatar
More information about martian/laravatar
Files in martian/laravatar
Package laravatar
Short Description 🚀 A lightweight and easy-to-use Laravel package that add avatars to your models
License MIT
Homepage https://github.com/amplifiedhq/laravatar
Informations about the package laravatar
Laravatar
🚀 A lightweight and easy-to-use Laravel package designed to simplify avatar generation for your Eloquent models. It provides a flexible and extensible solution for generating avatars using Gravatar, DiceBear, UI Avatars or Boring Avatar
Supported Avatar Drivers
Driver | Description | Supported | Link |
---|---|---|---|
Gravatar | Gravatar is a service for providing globally unique avatars. | Yes ✅️ | Gravatar |
DiceBear | DiceBear is an avatar library for designers and developers. | Yes ✅️ | DiceBear |
UI Avatars | UI Avatars is an avatar library for designers and developers. | Yes ✅️ | UI Avatars |
Boring Avatar | Boring avatars is a tiny JavaScript React library that generates custom, SVG-based, round avatars from any username and color palette. | Yes ✅️ | Boring Avatar |
[!NOTE] You can also add your own custom driver by implementing the
AmplifiedHQ\Laravatar\Contracts\AvatarInterface;
interface and extending theAmplifiedHQ\Laravatar\Abstracts\BaseAvatar
class.
Installation
Note: This package requires PHP 7.4 or higher. You can install the package via composer:
Register Service Provider
Add the service provider to the providers array in config/app.php
:
Publish Configuration File
Publish the configuration file using the following command:
Configuration
You can configure the package by editing the config/laravatar.php
file.
-
In the configuration file you can specify the default avatar driver to use across your application.
- If you want to change the default options for a driver, you can do so by editing the
config/laravatar.php
file.
Usage
In order to use the package in your model to generate an avatar on the fly, you need to add the AmplifiedHQ\Laravatar\Traits\HasAvatar
trait to your model.
Using the HasAvatar
trait
[!IMPORTANT] If you are using the
gravatar
driver, you need to use the email column as the avatar column. If you are using thedicebear
orui-avatars
orboringavatar
driver, you can use any column as the avatar column, provided that the column is a string column. (e.g.name
,username
etc.)[!WARNING] The
HasAvatar
trait requires you to define the$avatarColumn
and$avatarStorageColumn
properties in your model. The$avatarColumn
property is the column that will be used to generate the avatar. The$avatarStorageColumn
property is the column that will be used to store the avatar.
Using the Driver Methods
You can also use each driver method directly on your application either on on your controller, model or view.
Gravatar
DiceBear
Boring Avatar
UI Avatars
Testing
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email [email protected] instead of using the issue tracker.
Credits
- Josiah Endurance
- AbdulHameed
- All Contributors
License
The MIT License (MIT). Please see License File for more information.