39 lines
849 B
PHP
39 lines
849 B
PHP
<?php
|
|
|
|
namespace App\Livewire\Modals;
|
|
|
|
use App\Domains\Workspace\Actions\CreateWorkspace as CreateWorkspaceAction;
|
|
use LivewireUI\Modal\ModalComponent;
|
|
|
|
class CreateWorkspace extends ModalComponent
|
|
{
|
|
public string $name = '';
|
|
|
|
protected function rules(): array
|
|
{
|
|
return [
|
|
'name' => 'required|string|max:80',
|
|
];
|
|
}
|
|
|
|
public function create(): void
|
|
{
|
|
$this->validate();
|
|
|
|
$workspace = (new CreateWorkspaceAction)->handle(auth()->user(), ['name' => $this->name]);
|
|
|
|
$this->dispatch('workspaceCreated', workspaceUlid: $workspace->ulid);
|
|
$this->closeModal();
|
|
}
|
|
|
|
public static function modalMaxWidth(): string
|
|
{
|
|
return 'sm';
|
|
}
|
|
|
|
public function render(): \Illuminate\View\View
|
|
{
|
|
return view('livewire.modals.create-workspace');
|
|
}
|
|
}
|