Create Custom Page for Profile Edit

Hi Folks, I'm trying to set up a profile page in Filament v4 where only the edit operation will be performed, but I'm getting a 404 error at the "/profile" address. Could anyone help me about this issue?

<?php

namespace App\Filament\Pages;

use App\Models\User;
use Filament\Actions\Action;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Pages\Page;
use Filament\Schemas\Components\Form;
use Filament\Support\Exceptions\Halt;
use Notification;

class EditProfile extends Page implements HasForms
{
    use InteractsWithForms;
    public ?array $data = [];
    protected string $view = 'filament.pages.edit-profile';
    protected static string|BackedEnum|null $navigationIcon = Heroicon::PencilSquare;
    protected static ?string $slug = 'profile';
    public function mount(): void
    {
        $this->form->fill(auth()->user()->attributesToArray());
    }

    public function form(Form $form): Form
    {
        return $form
            ->schema([
                TextInput::make('name')
                    ->label('Hotel Name')
                    ->required(),
                TextInput::make('email')
                    ->label('Email Address')
                    ->email()
                    ->required(),
                TextInput::make('password')
                    ->label('Password')
                    ->password()
                    ->dehydrated(false)
                    ->nullable(),
                TextInput::make('password_confirmation')
                    ->label('Confirm Password')
                    ->password()
                    ->dehydrated(false)
                    ->nullable(),
            ])
            ->statePath('data');
    }
    protected function getFormActions(): array
    {
        return [
            Action::make('save')
                ->label(__('filament-panels::resources/pages/edit-record.form.actions.save.label'))
                ->submit('save'),
        ];
    }
    public function save(): void
    {
        try {
            $data = $this->form->getState();

            User::where('id', auth()->user()->id)->update($data);
        } catch (Halt $exception) {
            return;
        }
        Notification::make()
            ->success()
            ->title(__('filament-panels::resources/pages/edit-record.notifications.saved.title'))
            ->send();
    }
}


AdminPanelProvider.php
    ->pages([
        Dashboard::class,
        EditProfile::class,
    ])
    ->userMenuItems([
         'edit-profile' => MenuItem::make()
             ->label('Edit Profile')
             ->url('profile')
             ->icon('heroicon-o-pencil-square'),
     ])


resources/views/filament/pages/edit-profile.blade.php
<x-filament-panels::page>
    <x-filament-panels::form wire:submit="save"> 
        {{ $this->form }}
        <x-filament-panels::form.actions
            :actions="$this->getFormActions()"
        />
    </x-filament-panels::form>
</x-filament-panels::page>
Was this page helpful?