proclamatore = $proclamatore; $this->nome = $proclamatore->nome; $this->cognome = $proclamatore->cognome; $this->attivo = $proclamatore->attivo; } protected function rules(): array { return [ 'nome' => 'required|string|max:100', 'cognome' => 'required|string|max:100', 'attivo' => 'boolean', ]; } public function save() { $this->authorize('settings.manage'); $this->validate(); // Un sorvegliante reso non attivo scioglie il gruppo (Proclamatore::booted). $gruppo = ! $this->attivo ? $this->proclamatore->gruppoSorvegliato() : null; $this->proclamatore->update([ 'nome' => $this->nome, 'cognome' => $this->cognome, 'attivo' => $this->attivo, ]); $avviso = "Proclamatore {$this->proclamatore->nome_completo} aggiornato." . ($gruppo ? ' ' . ProclamatoreIndex::gruppoSciolto($gruppo) : ''); session()->flash('success', $avviso); return $this->redirect($this->destinazione(route('proclamatori.index')), navigate: true); } public function render() { return view('livewire.proclamatori.proclamatore-form', [ 'titolo' => "Modifica {$this->proclamatore->nome_completo}", 'btnLabel' => 'Salva Modifiche', 'gruppoSorvegliato' => $this->proclamatore->gruppoSorvegliato(), ]); } }