Customizing Username field in FilamentPHP Panels
Discover how to customize the default name field in FilamentPHP.
April 30, 2024
If you've used a different field for the user's name, such as username
instead of name
, you may have encountered an error stating that the name
field is not present on the User model.
To resolve this issue, you need to implement Filament's HasName
contract in your User
model.
use Filament\Models\Contracts\HasName;
class User extends Authenticatable implements FilamentUser, HasName
{
//....
public function getFilamentName(): string
{
return $this->username;
}
Filament will now use the getFilamentName()
method to retrieve the user's name.