class EditProfile extends Page implements HasForms
{
use Concerns\InteractsWithFormActions;
use InteractsWithForms;
protected static string $view = 'filament.pages.auth.edit-profile';
protected static ?string $slug = 'profil';
protected static bool $shouldRegisterNavigation = false;
public ?array $profileData = [];
public function mount(): void
{
$this->fillForms();
}
protected function getForms(): array
{
return [
'editProfileForm'
];
}
public function editProfileForm(Form $form): Form
{
return $form
->schema([
//Fields here
])
->model($this->getUser())
->statePath('profileData');
}
public function updateProfile(): void
{
try {
$data = $this->editProfileForm->getState();
$this->handleRecordUpdate($this->getUser(), $data);
} catch (Halt $exception) {
return;
}
$title = __('app.pages.auth.edit_profile.notifications.section_information');
$this->dispatch('myevent'); //<- My event
$this->sendSuccessNotification($title);
}
protected function getUpdateProfileFormActions(): array
{
return [
Action::make('updateProfileAction')
->label(__('filament-panels::pages/auth/edit-profile.form.actions.save.label'))
->submit('editProfileForm'),
];
}
protected function fillForms(): void
{
$data = $this->getUser()->attributesToArray();
$this->editProfileForm->fill($data);
}
}