2023-07-26 11:23:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
2023-12-07 18:06:32 +00:00
|
|
|
namespace App\Livewire\Project;
|
2023-07-26 11:23:47 +00:00
|
|
|
|
|
|
|
|
use App\Models\Project;
|
2024-11-05 08:36:40 +00:00
|
|
|
use Livewire\Attributes\Validate;
|
2023-07-26 11:23:47 +00:00
|
|
|
use Livewire\Component;
|
2025-01-07 13:52:08 +00:00
|
|
|
use Throwable;
|
2024-11-22 15:03:20 +00:00
|
|
|
use Visus\Cuid2\Cuid2;
|
2023-07-26 11:23:47 +00:00
|
|
|
|
|
|
|
|
class AddEmpty extends Component
|
|
|
|
|
{
|
2024-11-05 08:36:40 +00:00
|
|
|
#[Validate(['required', 'string', 'min:3'])]
|
2024-11-03 22:42:00 +00:00
|
|
|
public string $name;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-11-05 08:36:40 +00:00
|
|
|
#[Validate(['nullable', 'string'])]
|
2023-07-26 11:23:47 +00:00
|
|
|
public string $description = '';
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-07-26 11:23:47 +00:00
|
|
|
public function submit()
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
$this->validate();
|
2025-01-07 13:52:08 +00:00
|
|
|
$project = Project::query()->create([
|
2023-07-26 11:23:47 +00:00
|
|
|
'name' => $this->name,
|
|
|
|
|
'description' => $this->description,
|
2023-08-22 15:44:49 +00:00
|
|
|
'team_id' => currentTeam()->id,
|
2024-11-22 15:03:20 +00:00
|
|
|
'uuid' => (string) new Cuid2,
|
2023-07-26 11:23:47 +00:00
|
|
|
]);
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-12-27 15:45:01 +00:00
|
|
|
return redirect()->route('project.show', $project->uuid);
|
2025-01-07 13:52:08 +00:00
|
|
|
} catch (Throwable $e) {
|
2023-09-15 13:34:25 +00:00
|
|
|
return handleError($e, $this);
|
2023-07-26 11:23:47 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|