mailboxId = $mailboxId; $this->mailbox = MailUser::with('domain')->findOrFail($mailboxId); $this->email = $this->mailbox->localpart . '@' . $this->mailbox->domain->domain; } #[On('mailbox:delete')] public function delete(): void { // Optional: Export/Keep behandeln (hier nur Platzhalter-Events, damit UI fertig ist) if ($this->export_zip) { $this->dispatch('mailbox:export-zip', id: $this->mailboxId); } if ($this->keep_server_mail) { $this->dispatch('mailbox:keep-server-mail', id: $this->mailboxId); } $this->mailbox->delete(); $this->dispatch('mailbox:deleted'); $this->dispatch('closeModal'); $this->dispatch('toast', type: 'done', badge: 'Postfach', title: 'Postfach entfernt', text: 'Das Postfach ' . e($this->email) . ' wurde erfolgreich entfernt.', duration: 6000 ); } public function render() { return view('livewire.ui.mail.modal.mailbox-delete-modal'); } } //namespace App\Livewire\Ui\Mail\Modal; // //use App\Models\MailUser; //use LivewireUI\Modal\ModalComponent; // //class MailboxDeleteModal extends ModalComponent //{ // public int $domainId; // = mailbox_id // public string $email_display = ''; // // // Info-Badges // public int $quota_mb = 0; // public int $message_count = 0; // // // Auswahl // public string $mode = 'purge'; // purge | keep | export_then_delete // public string $confirm = ''; // // protected MailUser $mailbox; // // public function mount(int $domainId): void // { // $this->domainId = $domainId; // // $this->mailbox = MailUser::with('domain:id,domain')->findOrFail($this->domainId); // // $this->email_display = $this->mailbox->localpart . '@' . $this->mailbox->domain->domain; // $this->quota_mb = (int)$this->mailbox->quota_mb; // $this->message_count = (int)($this->mailbox->message_count ?? 0); // } // // public function delete(): void // { // if (trim(strtolower($this->confirm)) !== strtolower($this->email_display)) { // $this->addError('confirm', 'Bitte tippe die E-Mail exakt zur Bestätigung ein.'); // return; // } // // // Hier nur Platzhalter – deine eigentliche Lösch-/Exportlogik einsetzen // switch ($this->mode) { // case 'purge': // $this->mailbox->delete(); // break; // case 'keep': // // Account deaktivieren/löschen, Maildir auf dem Server behalten // $this->mailbox->delete(); // break; // case 'export_then_delete': // // Job anstoßen, ZIP exportieren, danach löschen // // dispatch(new \App\Jobs\ExportMailboxZipAndDelete($this->mailbox->id)); // $this->mailbox->delete(); // break; // } // // $this->dispatch('mailbox:deleted'); // $this->dispatch('closeModal'); // } // // public static function modalMaxWidth(): string // { // return '3xl'; // } // // public function render() // { // return view('livewire.ui.mail.modal.mailbox-delete-modal'); // } //} // //namespace App\Livewire\Ui\Mail\Modal; // //use App\Models\MailUser; //use LivewireUI\Modal\ModalComponent; // //class MailboxDeleteModal extends ModalComponent //{ // public int $mailboxId; // // public string $email = ''; // public ?int $quota_mb = null; // public int $message_count = 0; // // public string $confirm = ''; // public string $mode = 'purge'; // purge | keep_maildir | export_zip // // public function mount(int $mailboxId): void // { // $u = MailUser::findOrFail($mailboxId); // $this->mailboxId = $u->id; // $this->email = $u->email; // $this->quota_mb = (int)$u->quota_mb; // $this->message_count = (int)($u->message_count ?? 0); // } // // public function delete(): void // { // $this->validate([ // 'confirm' => ['required','same:email'], // 'mode' => ['required','in:purge,keep_maildir,export_zip'], // ]); // // $u = MailUser::findOrFail($this->mailboxId); // // // OPTION: Export anstoßen // if ($this->mode === 'export_zip') { // // TODO: z.B. Job dispatchen: // // MailboxExportJob::dispatch($u->id); // // oder Service: app(MailExportService::class)->exportAndStoreZip($u); // $this->dispatch('toast', // type: 'info', // badge: 'Export', // title: 'Mail-Export gestartet', // text: 'Der ZIP-Export wurde angestoßen. Du erhältst einen Download-Hinweis, sobald er fertig ist.', // duration: 6000, // ); // } // // // Account löschen: // // - purge: Maildir + Account entfernen // // - keep_maildir: NUR Account entfernen (Maildir bleibt – je nach MTA/Storage-Setup) // // Implementierung hängt von deiner Umgebung ab. Hier rufen wir Events, // // damit deine Listener/Services zielgerichtet handeln können. // if ($this->mode === 'purge') { // $this->dispatch('mailbox:purge', id: $u->id); // } elseif ($this->mode === 'keep_maildir') { // $this->dispatch('mailbox:delete-keep-storage', id: $u->id); // } else { // $this->dispatch('mailbox:export-and-delete', id: $u->id); // } // // // In jedem Fall den Datensatz entfernen: // $u->delete(); // // $this->dispatch('mailbox:deleted'); // $this->dispatch('closeModal'); // $this->dispatch('toast', // type: 'done', // badge: 'Mailbox', // title: 'Postfach gelöscht', // text: 'Das Postfach wurde entfernt.', // duration: 4000, // ); // } // // public static function modalMaxWidth(): string // { // return '2xl'; // } // // public function render() // { // return view('livewire.ui.mail.modal.mailbox-delete-modal'); // } //}