agenticmorf/fluxui-avatar
Drop-in avatar manager for Laravel 11 + Livewire 4 + Flux UI. Automatically displays the authenticated user’s avatar in <flux:avatar />, includes a ready-to-use upload component, validation, and storage via filesystem disk or Spatie Media Library—no starter-kit edits required.
composer require agenticmorf/fluxui-avatar
php artisan vendor:publish --tag=fluxui-avatar-config
config/fluxui-avatar.php and running migrations.<livewire:avatar-manager />
Profile Page Integration
Add <livewire:avatar-manager /> to your profile view (e.g., resources/views/profile.blade.php). The component handles:
Avatar Display
Use <flux:avatar /> anywhere in your app. The package automatically resolves the authenticated user’s avatar URL or falls back to initials.
<flux:avatar size="md" circle />
Upload Management
The <livewire:avatar-manager /> component handles:
<flux:file-upload>Storage Integration
avatar_path column (default: public/avatars/).spatie/laravel-medialibrary with avatars collection.fluxui-avatar.php:
'accepted_types' => ['jpg', 'png', 'gif'],
'max_file_size' => 5120, // 5MB
php artisan vendor:publish --tag=fluxui-avatar-views
AvatarStorage facade to fetch URLs:
use AgenticMorf\FluxuiAvatar\Facades\AvatarStorage;
$url = AvatarStorage::getUrl($user);
AvatarManager component injects AvatarStorageInterface via boot() (no manual resolution).wire:model.live for real-time previews:
<flux:file-upload wire:model.live="photo" />
rules() method:
public function rules(): array
{
return [
'photo' => 'nullable|image|mimes:jpg,png|max:2048',
];
}
Namespace Shadowing Recursion
<flux:avatar> in the shadowed view causes infinite loops.@include('flux::avatar.index', ['src' => $avatarUrl])
Spatie Media Library Setup
singleFile() in registerMediaCollections() causes duplicate avatars.User model includes:
$this->addMediaCollection('avatars')->singleFile();
Disk Driver Paths
avatar_path column is misconfigured.directory in config matches your storage path (e.g., public/avatars).Livewire 4 Migration
#[LivewireProperty] or WithFileUploads trait (v3 syntax).use Livewire\Features\SupportFileUploads.AvatarStorageInterface:
public function getUrl(User $user): ?string
{
$url = $this->resolveUrl($user);
\Log::debug("Avatar URL for {$user->id}: {$url}");
return $url;
}
FLUXUI_AVATAR_DRIVER in .env matches your config.php artisan view:clear
Custom Storage Adapters
Implement AgenticMorf\FluxuiAvatar\Contracts\AvatarStorageInterface for new backends (e.g., S3):
class S3Adapter implements AvatarStorageInterface
{
public function store(File $file, User $user): void
{
// Custom S3 logic
}
// ...
}
Bind it in the service provider:
$this->app->when(AvatarStorageInterface::class)
->needs(S3Adapter::class)
->give(fn() => new S3Adapter());
Override Avatar Logic
Extend the AvatarManager component to add features (e.g., cropper):
public function mount()
{
$this->photo = null;
$this->cropperEnabled = config('fluxui-avatar.cropper', false);
}
Custom Initials Logic
Override the generateInitials() method in your shadowed avatar.blade.php:
@php
$initials = Str::of($name)->take(2)->upper()->replace([' ', '-'], '');
@endphp
'default_avatar' => 'https://example.com/default-avatar.png',
avatars directory is writable:
chmod -R 755 storage/app/public/avatars
spatie/laravel-medialibrary:
php artisan migrate
How can I help you explore Laravel packages today?