2023-06-22 07:33:26 +00:00
|
|
|
<?php
|
|
|
|
|
2023-12-07 18:06:32 +00:00
|
|
|
namespace App\Livewire\Project;
|
2023-06-22 07:33:26 +00:00
|
|
|
|
|
|
|
use App\Models\Project;
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class Edit extends Component
|
|
|
|
{
|
|
|
|
public Project $project;
|
|
|
|
protected $rules = [
|
|
|
|
'project.name' => 'required|min:3|max:255',
|
|
|
|
'project.description' => 'nullable|string|max:255',
|
|
|
|
];
|
2024-01-07 15:23:41 +00:00
|
|
|
public function mount() {
|
|
|
|
$projectUuid = request()->route('project_uuid');
|
|
|
|
$teamId = currentTeam()->id;
|
|
|
|
$project = Project::where('team_id', $teamId)->where('uuid', $projectUuid)->first();
|
|
|
|
if (!$project) {
|
|
|
|
return redirect()->route('dashboard');
|
|
|
|
}
|
|
|
|
$this->project = $project;
|
|
|
|
}
|
2023-06-22 13:25:57 +00:00
|
|
|
|
2023-06-22 07:33:26 +00:00
|
|
|
public function submit()
|
|
|
|
{
|
|
|
|
$this->validate();
|
|
|
|
try {
|
|
|
|
$this->project->save();
|
2023-12-07 18:06:32 +00:00
|
|
|
$this->dispatch('saved');
|
2023-09-11 15:36:30 +00:00
|
|
|
} catch (\Throwable $e) {
|
2023-09-15 13:34:25 +00:00
|
|
|
return handleError($e, $this);
|
2023-06-22 07:33:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|