coolify/app/Livewire/Project/Edit.php

38 lines
951 B
PHP
Raw Normal View History

2023-06-22 09:33:26 +02:00
<?php
2023-12-07 19:06:32 +01:00
namespace App\Livewire\Project;
2023-06-22 09:33:26 +02: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-23 17:13:23 +01:00
public function mount()
{
2024-01-07 16:23:41 +01:00
$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 15:25:57 +02:00
2023-06-22 09:33:26 +02:00
public function submit()
{
try {
2024-03-21 14:30:35 +01:00
$this->validate();
2023-06-22 09:33:26 +02:00
$this->project->save();
2023-12-07 19:06:32 +01:00
$this->dispatch('saved');
2024-03-21 14:30:35 +01:00
$this->dispatch('success', 'Project updated.');
2023-09-11 17:36:30 +02:00
} catch (\Throwable $e) {
return handleError($e, $this);
2023-06-22 09:33:26 +02:00
}
}
}