davidpiesse/nova-avatars
Nova Avatars adds avatar support to Laravel Nova resources, letting you display user or model images—such as Gravatars or uploaded files—directly in Nova fields and index views. A small helper for cleaner, more personable admin panels.
composer require <vendor>/<package>:^0.0.3
src/ first. In an early 0.0.x package, the README is often the only reliable contract. Look for the facade/helper entry point, the config file, and any tests that demonstrate expected input/output.php artisan vendor:publish --provider="Vendor\Package\PackageServiceProvider"
"JD" from "John Doe" and render it inside a styled circle:
<div class="avatar">
{{ $user->initials ?? '?' }}
</div>
0.0.3 is the first release that explicitly mentions initials, verify the exact method name and signature in the package source before wiring it into models or shared Blade components. Treat the API as provisional until you pin a version in composer.json.Model accessor or presenter
public function getInitialsAttribute(): string
{
return Initials::from($this->name);
}
Keep the package call behind your own accessor so a future package API change only touches one place.
Blade component
// app/View/Components/Avatar.php
public function __construct(public string $name) {}
public function initials(): string
{
return Initials::from($this->name);
}
Use the component anywhere a user, team, or contact needs a fallback avatar.
API resources
Include initials in API payloads only if clients actually need them. Otherwise generate them in the frontend and avoid coupling your API contract to a 0.0.x package:
return [
'name' => $this->name,
'initials' => Initials::from($this->name),
];
Bulk generation For imports, seeders, or backfills, call the package in a job or chunked query rather than per-row in a controller. Cache results if initials are rendered on every request:
Cache::remember("user:{$user->id}:initials", now()->addDay(), fn () => Initials::from($user->name));
Testing Write your own unit tests around edge cases instead of relying solely on the package’s coverage:
it('generates initials', function () {
expect(Initials::from('John Doe'))->toBe('JD');
});
Add cases for single names, multiple middle names, hyphens, apostrophes, and non-Latin characters.
Localization and display Keep the package responsible for extraction only. Formatting, uppercase/lowercase, separators, and avatar colors should remain in your app so they can follow your design system.
0.0.3 is pre-1.0. Pin an exact version (0.0.3) and avoid ^0.0.3 in production if you need reproducible installs. Expect method names and return formats to change.initials(), from(), or a facade. Confirm whether it returns a string, array, or object.substr is not multibyte-safe; verify the package uses mb_* functions.Dr., Jr.), hyphenated names, and names with multiple middle names. Decide your own fallback (?, first letter, or a default avatar).{{ }}), especially if the package returns raw HTML or SVG in future versions.php artisan config:cache in deployment. Test that package behavior still works after caching.composer.json for extra.laravel.providers and extra.laravel.aliases.How can I help you explore Laravel packages today?