organization = $organization; if ($contact?->exists) { $this->contact = $contact; $this->first_name = $contact->first_name; $this->last_name = $contact->last_name; $this->title = $contact->title ?? ''; $this->email = $contact->email ?? ''; $this->phone = $contact->phone ?? ''; $this->mobile = $contact->mobile ?? ''; $this->location_id = $contact->location_id; $this->is_important = $contact->is_important; $this->notes = $contact->notes ?? ''; } } public function save(): void { $validated = $this->validate([ 'first_name' => 'required|string|max:255', 'last_name' => 'required|string|max:255', 'title' => 'nullable|string|max:255', 'email' => 'nullable|email|max:255', 'phone' => 'nullable|string|max:255', 'mobile' => 'nullable|string|max:255', 'location_id' => 'nullable|exists:locations,id', 'is_important' => 'boolean', 'notes' => 'nullable|string', ]); if ($this->contact?->exists) { $this->contact->update($validated); session()->flash('status', "Contact \"{$this->contact->full_name}\" mis à jour."); } else { $this->organization->contacts()->create($validated); session()->flash('status', "Contact \"{$this->first_name} {$this->last_name}\" créé."); } $this->redirectRoute('organizations.contacts.index', $this->organization, navigate: true); } public function with(): array { return [ 'locations' => $this->organization->locations()->orderBy('name')->get(), ]; } }; ?>

{{ $organization->name }}

{{ $contact?->exists ? 'Modifier le contact' : 'Nouveau contact' }}

@error('first_name')

{{ $message }}

@enderror
@error('last_name')

{{ $message }}

@enderror
@error('email')

{{ $message }}

@enderror
Annuler