coolify/app/Livewire/Project/AddEmpty.php

42 lines
936 B
PHP
Raw Normal View History

<?php
2023-12-07 19:06:32 +01:00
namespace App\Livewire\Project;
use App\Models\Project;
use Livewire\Component;
class AddEmpty extends Component
{
public string $name = '';
2024-06-10 22:43:34 +02:00
public string $description = '';
2024-06-10 22:43:34 +02:00
protected $rules = [
'name' => 'required|string|min:3',
'description' => 'nullable|string',
];
2024-06-10 22:43:34 +02:00
protected $validationAttributes = [
'name' => 'Project Name',
'description' => 'Project Description',
];
public function submit()
{
try {
$this->validate();
$project = Project::create([
'name' => $this->name,
'description' => $this->description,
2023-08-22 17:44:49 +02:00
'team_id' => currentTeam()->id,
]);
2024-06-10 22:43:34 +02:00
2023-12-27 16:45:01 +01:00
return redirect()->route('project.show', $project->uuid);
2023-09-11 17:36:30 +02:00
} catch (\Throwable $e) {
return handleError($e, $this);
} finally {
$this->name = '';
}
}
}