lasthourcloud/app/Http/Livewire/Project/AddEmpty.php

38 lines
937 B
PHP
Raw Normal View History

<?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',
];
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,
]);
return redirect()->route('project.show', $project->uuid);
2023-09-11 15:36:30 +00:00
} catch (\Throwable $e) {
return handleError($e, $this);
} finally {
$this->name = '';
}
}
}