I've tried to do the exact thing like the filament documentation and the user avatar image not showing. Here's my code in User Model :
use Filament\Models\Contracts\HasAvatar;
class User extends Authenticatable implements HasAvatar
{
use HasApiTokens, HasFactory, Notifiable, HasRoles;
/**
* The attributes that are mass assignable.
*
* @var array<int, string>
*/
protected $guarded = [
'id'
];
/**
* The attributes that should be hidden for serialization.
*
* @var array<int, string>
*/
protected $hidden = [
'password',
'remember_token',
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'email_verified_at' => 'datetime',
'password' => 'hashed',
];
public function getFilamentAvatarUrl(): ?string
{
return $this->photo;
}
}
Needs to return probably the full correct path to the image. What do you store in your database? Just a filename? If so then it needs to be full path. That path should open your avatar if you paste it into the browser directly - thats the easiest way to check if it works.