FilamentF
Filament3y ago
Abi

No morph map defined for model

I get the following error on the edit page of the User Resource on the admin panel and not sure what may be the issue

No morph map defined for model [App\Models\User].


My form method has the following code
 public static function form(Form $form): Form
    {
        return $form
            ->schema([
                Forms\Components\TextInput::make('name')
                    ->required()
                    ->disabled()
                    ->maxLength(255),
                Forms\Components\TextInput::make('email')
                    ->email()
                    ->required()
                    ->disabled()
                    ->maxLength(255),
                Forms\Components\TextInput::make('additionalDetail.user_type')
                    ->label('User Type'),

                Forms\Components\Fieldset::make('Address')
                    ->relationship('additionalDetail')
                    ->disabled()
                    ->schema([
                        Forms\Components\TextInput::make('phone'),
                        Forms\Components\TextInput::make('city')
                            ->label('City')
                            ->maxLength(255),
                        Forms\Components\TextInput::make('user_type')
                            ->label('User Type')
                            ->maxLength(255),
                    ]),
            ]);
    }

and the relation on the User model is as follows:

    public function additionalDetail(): HasOne
    {
        return $this->hasOne(UserAdditionalDetail::class, 'user_id', 'id');
    }


User model has the following additions from the default

class User extends Authenticatable implements MustVerifyEmail, FilamentUser
{
    use HasApiTokens;
    use HasFactory;
    use HasProfilePhoto;
    use Notifiable;
    use TwoFactorAuthenticatable;
    use HasRoles;

    protected $guard_name = 'web';
Was this page helpful?