49 lines
1.1 KiB
PHP
49 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Modals;
|
|
|
|
use App\Domains\Webhook\Models\Webhook;
|
|
use Illuminate\View\View;
|
|
use LivewireUI\Modal\ModalComponent;
|
|
|
|
class DeleteWebhook extends ModalComponent
|
|
{
|
|
public int $webhookId = 0;
|
|
|
|
public string $webhookUrl = '';
|
|
|
|
public function mount(int $webhookId): void
|
|
{
|
|
$workspace = app('current_workspace');
|
|
$webhook = Webhook::where('id', $webhookId)
|
|
->where('workspace_id', $workspace->id)
|
|
->firstOrFail();
|
|
|
|
$this->webhookId = $webhookId;
|
|
$this->webhookUrl = $webhook->url;
|
|
}
|
|
|
|
public function delete(): void
|
|
{
|
|
$workspace = app('current_workspace');
|
|
|
|
Webhook::where('id', $this->webhookId)
|
|
->where('workspace_id', $workspace->id)
|
|
->firstOrFail()
|
|
->delete();
|
|
|
|
$this->dispatch('webhookDeleted', webhookId: $this->webhookId);
|
|
$this->closeModal();
|
|
}
|
|
|
|
public static function modalMaxWidth(): string
|
|
{
|
|
return 'sm';
|
|
}
|
|
|
|
public function render(): View
|
|
{
|
|
return view('livewire.modals.delete-webhook');
|
|
}
|
|
}
|