50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Modals;
|
|
|
|
use App\Domains\Bio\Models\BioPage;
|
|
use Illuminate\View\View;
|
|
use LivewireUI\Modal\ModalComponent;
|
|
|
|
class DeleteBioPage extends ModalComponent
|
|
{
|
|
public string $bioUlid = '';
|
|
|
|
public string $bioTitle = '';
|
|
|
|
public function mount(string $bioUlid): void
|
|
{
|
|
$workspace = app('current_workspace');
|
|
$bio = BioPage::where('ulid', $bioUlid)
|
|
->where('workspace_id', $workspace->id)
|
|
->firstOrFail();
|
|
|
|
$this->bioUlid = $bioUlid;
|
|
$this->bioTitle = $bio->getTranslation('title', 'en') ?? $bio->slug;
|
|
}
|
|
|
|
public function delete(): void
|
|
{
|
|
$workspace = app('current_workspace');
|
|
|
|
BioPage::where('ulid', $this->bioUlid)
|
|
->where('workspace_id', $workspace->id)
|
|
->firstOrFail()
|
|
->delete();
|
|
|
|
$this->dispatch('bioPageDeleted', bioUlid: $this->bioUlid);
|
|
$this->dispatch('toast', message: 'Bio Page gelöscht', type: 'success');
|
|
$this->closeModal();
|
|
}
|
|
|
|
public static function modalMaxWidth(): string
|
|
{
|
|
return 'sm';
|
|
}
|
|
|
|
public function render(): View
|
|
{
|
|
return view('livewire.modals.delete-bio-page');
|
|
}
|
|
}
|