Interface "App\Filament\AvatarProviders\Contracts\AvatarProvider" not found

I have created a file BoringAvatarsProvider.php in app/Filament/AvatarProviders/
and put there this:
<?php
 
namespace App\Filament\AvatarProviders;
 
use Filament\Facades\Filament;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Database\Eloquent\Model;
 
class BoringAvatarsProvider implements Contracts\AvatarProvider
{
    public function get(Model | Authenticatable $record): string
    {
        $name = str(Filament::getNameForDefaultAvatar($record))
            ->trim()
            ->explode(' ')
            ->map(fn (string $segment): string => filled($segment) ? mb_substr($segment, 0, 1) : '')
            ->join(' ');
 
        return 'https://source.boringavatars.com/beam/120/' . urlencode($name);
    }
}


and added this to panel:

->defaultAvatarProvider(BoringAvatarsProvider::class);

And I am getting the error message:

Interface "App\Filament\AvatarProviders\Contracts\AvatarProvider" not found


In the editor the part : implements Contracts\AvatarProvider

has Contracts\AvatarProvider with a yellow background and it says on hover:

undefined namespace Contracts.

Do I need to create some other files to make this work?

I have followed the docs here https://filamentphp.com/docs/3.x/panels/users#using-a-different-avatar-provider and there is nothing else to do, no mention about creating additional files, just this one BoringAvatarsProvider.php and putting the ->defaultAvatarProvider(BoringAvatarsProvider::class); in the panel chain.
Solution
You saw my PR, right? So this is solved?
Was this page helpful?