42 lines
948 B
PHP
42 lines
948 B
PHP
<?php
|
|
|
|
namespace App\Livewire\Modals;
|
|
|
|
use App\Domains\Domain\Actions\CreateDomain;
|
|
use Illuminate\View\View;
|
|
use LivewireUI\Modal\ModalComponent;
|
|
|
|
class AddDomain extends ModalComponent
|
|
{
|
|
public string $hostname = '';
|
|
|
|
protected function rules(): array
|
|
{
|
|
return [
|
|
'hostname' => 'required|string|max:255|regex:/^[a-z0-9]([a-z0-9\-\.]+[a-z0-9])?$/i|unique:domains,hostname',
|
|
];
|
|
}
|
|
|
|
public function save(): void
|
|
{
|
|
$this->validate();
|
|
$workspace = app('current_workspace');
|
|
|
|
(new CreateDomain)->handle($workspace, $this->hostname);
|
|
|
|
$this->dispatch('domainAdded');
|
|
$this->dispatch('toast', message: 'Domain hinzugefügt', type: 'success');
|
|
$this->closeModal();
|
|
}
|
|
|
|
public static function modalMaxWidth(): string
|
|
{
|
|
return 'md';
|
|
}
|
|
|
|
public function render(): View
|
|
{
|
|
return view('livewire.modals.add-domain');
|
|
}
|
|
}
|