customer = $customer; $this->first_name = $customer->first_name; $this->last_name = $customer->last_name; $this->email = $customer->email; $this->phone = $customer->phone; $this->secondary_phone = $customer->secondary_phone; $this->address = $customer->address; $this->city = $customer->city; $this->state = $customer->state; $this->zip_code = $customer->zip_code; $this->notes = $customer->notes; $this->status = $customer->status; } public function updateCustomer() { // Update validation rules to exclude current customer's email $this->validate([ 'first_name' => 'required|string|max:255', 'last_name' => 'required|string|max:255', 'email' => 'required|email|max:255|unique:customers,email,' . $this->customer->id, 'phone' => 'required|string|max:20', 'secondary_phone' => 'nullable|string|max:20', 'address' => 'required|string|max:500', 'city' => 'required|string|max:255', 'state' => 'required|string|max:255', 'zip_code' => 'required|string|max:10', 'notes' => 'nullable|string|max:1000', 'status' => 'required|in:active,inactive', ]); $this->customer->update([ 'first_name' => $this->first_name, 'last_name' => $this->last_name, 'email' => $this->email, 'phone' => $this->phone, 'secondary_phone' => $this->secondary_phone, 'address' => $this->address, 'city' => $this->city, 'state' => $this->state, 'zip_code' => $this->zip_code, 'notes' => $this->notes, 'status' => $this->status, ]); session()->flash('success', 'Customer updated successfully!'); return $this->redirect('/customers/' . $this->customer->id, navigate: true); } public function render() { return view('livewire.customers.edit'); } }