User Avatar manager dependency for Laravel Enso
laravel-enso/avatars is a Laravel package for user avatar manager dependency for laravel enso.
It currently has 6 GitHub stars and 44.437 downloads on Packagist (latest version 4.5.7).
Install it with composer require laravel-enso/avatars.
Discover more Laravel packages by laravel-enso
or browse all Laravel packages to compare alternatives.
Last updated
Avatars is Laravel Enso's user avatar package.
It attaches one avatar record to each user, exposes authenticated endpoints for viewing, uploading, and regenerating avatars, and integrates with Enso's file pipeline so custom uploads are stored and transformed consistently.
The package also generates default avatars automatically. It prefers Gravatar when a public image exists for the user's email address and falls back to a locally generated Laravolt avatar when it does not.
The frontend integration lives primarily in the Enso user profile experience and reusable avatar components from @enso-ui/users.
This package comes pre-installed in Laravel Enso applications that support user profile avatars.
For standalone installation in an Enso-based application:
composer require laravel-enso/avatars
The package auto-registers its service providers, loads migrations, registers API routes, observes user creation, and exposes the avatar generation command.
Run the migrations after installation:
php artisan migrate
If you need the package storage scaffolding, publish it with:
php artisan vendor:publish --tag=avatars-storage
LaravelEnso\Users\Models\User through dynamic methods.generateAvatar() dynamic method to users for regenerating their default avatar.laravel-enso/files.The package binds an avatar() relation and generateAvatar() method to the Enso user model:
$user->avatar;
$user->generateAvatar();
Store a custom uploaded avatar for the authenticated user:
use Illuminate\Http\UploadedFile;
$request->validate([
'avatar' => 'required|image:allow_svg|dimensions:ratio=1',
]);
$request->user()->avatar->store(
UploadedFile::fake()->image('avatar.png', 512, 512),
);
Regenerate the default avatar:
$request->user()->generateAvatar();
Display an avatar in the browser by hitting the show endpoint:
route('core.avatars.show', $user->avatar->id);
::: warning Note The package is designed to work with a single avatar per user. When you regenerate or upload a new avatar, the previously attached file is removed automatically. :::
All package routes are registered under:
api/core/avatarscore.avatars.api, auth, coreEndpoints:
POST /api/core/avatarsPATCH /api/core/avatars/{avatar}GET /api/core/avatars/{avatar}LaravelEnso\Avatars\Policies\AvatarPolicy
LaravelEnso\Avatars\Models\Avatar
Persisted fields:
user_idfile_idurlRelationships:
user()file()Useful methods:
store(UploadedFile $uploadedFile)extensions()mimeTypes()imageWidth()imageHeight()Dynamic additions on LaravelEnso\Users\Models\User:
avatar()generateAvatar()Generate missing avatars for users without one:
php artisan enso:avatars:generate
Required Enso packages:
laravel-enso/core ↗laravel-enso/dynamic-methods ↗laravel-enso/files ↗laravel-enso/image-transformer ↗laravel-enso/migrator ↗laravel-enso/users ↗Companion frontend package:
External dependency:
are welcome. Pull requests are great, but issues are good too.
Thank you to all the people who already contributed to Enso!