Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Nova Vue Avatar Laravel Package

marispro/nova-vue-avatar

A lightweight Laravel Nova field for showing user avatars throughout your admin panel. Built with Vue, it renders profile images with graceful fallbacks so resource lists and detail views stay clean and consistent. Quick to install, simple to configure, and easy to style to match your Nova theme.

View on GitHub
Deep Wiki
Context7

Getting Started

Install the package with Composer and, if the service provider is not auto-discovered, register it (Laravel 5.5+ auto-discovers). The core entry point is the Avatar facade/builder:

use Avatar;

$svg = Avatar::make('John Doe')->toSvg(); // check README for the exact terminal render method

Where to look first:

  1. The package README for the terminal method (toSvg(), toHtml(), generate(), or similar) and the supported fluent options.
  2. Any publishable config (php artisan vendor:publish --tag=avatar-config or per the README) for default shape, font, size, and color palette.
  3. The Avatar::make(...) builder class itself — it is the main extension point and the fastest way to discover undocumented fluent methods.

First use case: replace a Gravatar/placeholder fallback with a locally generated initials avatar on the user profile page:

<img src="{{ route('avatar', $user) }}" alt="{{ $user->name }}">

or inline the SVG directly to avoid an extra request:

{!! Avatar::make($user->name)->background('#4f46e5')->toSvg() !!}

Implementation Patterns

Model accessor for a stable avatar URL. Wrap generation behind an accessor or dedicated AvatarService so controllers and views never call the facade directly:

public function getAvatarUrlAttribute(): string
{
    return route('avatar.show', $this);
}

Deterministic color from a stable key. Rather than randomizing backgrounds, derive them from the user so the avatar is consistent across requests and caches:

$palette = ['#4f46e5', '#0ea5e9', '#10b981', '#f59e0b', '#ef4444'];
$color = $palette[crc32($user->email) % count($palette)];

Avatar::make($user->name)->background($color);

Cache the rendered SVG. SVG generation is cheap but not free; for list views (comments, team pages) cache per user and invalidate on name/color change:

$svg = Cache::remember("avatar:{$user->id}:{$user->updated_at}", now()->addDay(), fn () =>
    Avatar::make($user->name)->background($user->avatar_color)->toSvg()
);

Serve via a controller route when you need HTTP caching, ETags, or to keep markup out of JSON payloads. Return response($svg)->header('Content-Type', 'image/svg+xml').

Store to disk for email/PDF contexts where inline SVG is not usable — render once on save (or in a queued job) and persist a PNG/SVG path on the model.

Blade component for consistency across views, with background defaulting from config and overridable per call site:

<x-avatar :name="$user->name" :background="$user->avatar_color ?? null" />

Release 0.6 integration: ->background('red') is additive and non-breaking. Adopt it where you previously post-processed SVG strings or wrapped avatars in a colored <div> — inline backgrounds are cleaner and survive export to files. Accepts named CSS colors; verify hex/rgb support against the README before relying on it.

Gotchas and Tips

  • Contrast is on you. A light background ('yellow', '#fde68a') with the default white/near-white initials is unreadable. Either pick a constrained palette or check whether the package exposes a foreground/text-color option alongside background().
  • Validate user-supplied colors. If background() can receive request input, whitelist a palette or validate with a regex — an unvalidated value lands in an SVG fill attribute.
  • Escape the name. Initials derived from user input must be escaped before they hit raw SVG output. Prefer the package's escaping over {!! !!} if it does not escape by default.
  • Multibyte names. Check how the package derives initials for names with accents, CJK characters, or emoji — test "Ólafsdóttir", "李雷", and single-word names rather than assuming substr-style behavior.
  • Cache invalidation. Any cached avatar keyed only on user_id will go stale when the name or background changes; include updated_at or a hash of the inputs in the key.
  • Config publishing drift. If you publish the config in 0.6, diff it against the package default — minor releases can add keys your published copy lacks, silently ignoring new options.
  • SVG in <img> vs inline. External SVGs cannot load custom fonts unless embedded; if the font matters, inline the markup or convert to a path/PNG.
  • Queue/PDF contexts. DomPDF and most mail clients do not render inline SVG reliably — generate a raster format or store a PNG for those paths.
  • Upgrade safety. 0.6 adds one optional fluent method with no signature changes; upgrading from 0.5 should require no code changes. Pin to ^0.6 and run your avatar tests to confirm output is byte-identical for existing calls.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin
skyraptor/chatter
edlugz/sasapay
abbasudo/artisan-route