50 lines
1.1 KiB
PHP
50 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Modals;
|
|
|
|
use App\Domains\QrCode\Models\QrCode;
|
|
use Illuminate\View\View;
|
|
use LivewireUI\Modal\ModalComponent;
|
|
|
|
class DeleteQrCode extends ModalComponent
|
|
{
|
|
public string $qrUlid = '';
|
|
|
|
public string $qrLabel = '';
|
|
|
|
public function mount(string $qrUlid): void
|
|
{
|
|
$workspace = app('current_workspace');
|
|
$qr = QrCode::where('ulid', $qrUlid)
|
|
->where('workspace_id', $workspace->id)
|
|
->firstOrFail();
|
|
|
|
$this->qrUlid = $qrUlid;
|
|
$this->qrLabel = $qr->label ?? $qr->ulid;
|
|
}
|
|
|
|
public function delete(): void
|
|
{
|
|
$workspace = app('current_workspace');
|
|
|
|
QrCode::where('ulid', $this->qrUlid)
|
|
->where('workspace_id', $workspace->id)
|
|
->firstOrFail()
|
|
->delete();
|
|
|
|
$this->dispatch('qrDeleted', qrUlid: $this->qrUlid);
|
|
$this->dispatch('toast', message: 'QR Code gelöscht', type: 'success');
|
|
$this->closeModal();
|
|
}
|
|
|
|
public static function modalMaxWidth(): string
|
|
{
|
|
return 'sm';
|
|
}
|
|
|
|
public function render(): View
|
|
{
|
|
return view('livewire.modals.delete-qr-code');
|
|
}
|
|
}
|