2023-07-26 11:23:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Livewire\Project;
|
|
|
|
|
|
|
|
use App\Models\Project;
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class AddEmpty extends Component
|
|
|
|
{
|
|
|
|
public string $name = '';
|
|
|
|
public string $description = '';
|
|
|
|
protected $rules = [
|
|
|
|
'name' => 'required|string|min:3',
|
|
|
|
'description' => 'nullable|string',
|
|
|
|
];
|
|
|
|
protected $validationAttributes = [
|
|
|
|
'name' => 'Project Name',
|
|
|
|
'description' => 'Project Description',
|
|
|
|
];
|
2023-08-08 09:51:36 +00:00
|
|
|
|
2023-07-26 11:23:47 +00:00
|
|
|
public function submit()
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
$this->validate();
|
|
|
|
$project = Project::create([
|
|
|
|
'name' => $this->name,
|
|
|
|
'description' => $this->description,
|
2023-08-22 15:44:49 +00:00
|
|
|
'team_id' => currentTeam()->id,
|
2023-07-26 11:23:47 +00:00
|
|
|
]);
|
|
|
|
return redirect()->route('project.show', $project->uuid);
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
general_error_handler($e, $this);
|
|
|
|
} finally {
|
|
|
|
$this->name = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|