contactId = $contactId; $contact = Contact::findOrFail($contactId); $this->first_name = $contact->first_name; $this->last_name = $contact->last_name; $this->email = $contact->email; $this->phone = $contact->phone ?? ''; $this->resetValidation(); Flux::modal('edit-contact')->show(); } public function save(): void { $this->validate([ 'first_name' => 'required|string|max:255', 'last_name' => 'required|string|max:255', 'email' => 'required|email|max:255|unique:contacts,email,' . $this->contactId, 'phone' => 'nullable|string|max:20', ]); $contact = Contact::findOrFail($this->contactId); $contact->update([ 'first_name' => $this->first_name, 'last_name' => $this->last_name, 'email' => $this->email, 'phone' => $this->phone ?: null, ]); $this->reset(); Flux::modal('edit-contact')->close(); $this->dispatch('contact-updated'); } }; ?>
Edit Contact
Save