58 lines
1.6 KiB
PHP
58 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire\Modals;
|
|
|
|
use App\Domains\Domain\Actions\VerifyDomain as VerifyDomainAction;
|
|
use App\Domains\Domain\Models\Domain;
|
|
use Illuminate\View\View;
|
|
use LivewireUI\Modal\ModalComponent;
|
|
|
|
class VerifyDomain extends ModalComponent
|
|
{
|
|
public int $domainId = 0;
|
|
|
|
public string $hostname = '';
|
|
|
|
public string $verificationToken = '';
|
|
|
|
public function mount(int $domainId): void
|
|
{
|
|
$workspace = app('current_workspace');
|
|
$domain = Domain::where('id', $domainId)
|
|
->where('workspace_id', $workspace->id)
|
|
->firstOrFail();
|
|
|
|
$this->domainId = $domainId;
|
|
$this->hostname = $domain->hostname;
|
|
$this->verificationToken = $domain->verification_token;
|
|
}
|
|
|
|
public function verify(): void
|
|
{
|
|
$workspace = app('current_workspace');
|
|
$domain = Domain::where('id', $this->domainId)
|
|
->where('workspace_id', $workspace->id)
|
|
->firstOrFail();
|
|
|
|
$verified = (new VerifyDomainAction)->handle($domain);
|
|
|
|
if ($verified) {
|
|
$this->dispatch('domainVerified', domainId: $this->domainId);
|
|
$this->dispatch('toast', message: 'Domain verifiziert', type: 'success');
|
|
$this->closeModal();
|
|
} else {
|
|
$this->dispatch('toast', message: 'DNS-Eintrag nicht gefunden. Bitte warten und erneut versuchen.', type: 'error');
|
|
}
|
|
}
|
|
|
|
public static function modalMaxWidth(): string
|
|
{
|
|
return 'md';
|
|
}
|
|
|
|
public function render(): View
|
|
{
|
|
return view('livewire.modals.verify-domain');
|
|
}
|
|
}
|