2023-12-30 13:47:26 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Livewire\Project;
|
|
|
|
|
|
|
|
use App\Models\Application;
|
|
|
|
use App\Models\Project;
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class EnvironmentEdit extends Component
|
|
|
|
{
|
|
|
|
public Project $project;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-12-30 13:47:26 +00:00
|
|
|
public Application $application;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-12-30 13:47:26 +00:00
|
|
|
public $environment;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-12-30 13:47:26 +00:00
|
|
|
public array $parameters;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-12-30 13:47:26 +00:00
|
|
|
protected $rules = [
|
|
|
|
'environment.name' => 'required|min:3|max:255',
|
|
|
|
'environment.description' => 'nullable|min:3|max:255',
|
|
|
|
];
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-01-23 16:13:23 +00:00
|
|
|
public function mount()
|
|
|
|
{
|
|
|
|
$this->parameters = get_route_parameters();
|
2023-12-30 13:47:26 +00:00
|
|
|
$this->project = Project::ownedByCurrentTeam()->where('uuid', request()->route('project_uuid'))->first();
|
|
|
|
$this->environment = $this->project->environments()->where('name', request()->route('environment_name'))->first();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function submit()
|
|
|
|
{
|
|
|
|
$this->validate();
|
|
|
|
try {
|
|
|
|
$this->environment->save();
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-12-30 13:47:26 +00:00
|
|
|
return redirect()->route('project.environment.edit', ['project_uuid' => $this->project->uuid, 'environment_name' => $this->environment->name]);
|
|
|
|
} catch (\Throwable $e) {
|
|
|
|
return handleError($e, $this);
|
|
|
|
}
|
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-12-30 13:47:26 +00:00
|
|
|
public function render()
|
|
|
|
{
|
|
|
|
return view('livewire.project.environment-edit');
|
|
|
|
}
|
|
|
|
}
|