2023-07-26 11:23:47 +00:00
|
|
|
<?php
|
|
|
|
|
2023-12-07 18:06:32 +00:00
|
|
|
namespace App\Livewire\Project;
|
2023-07-26 11:23:47 +00:00
|
|
|
|
|
|
|
use App\Models\Environment;
|
|
|
|
use App\Models\Project;
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class AddEnvironment extends Component
|
|
|
|
{
|
|
|
|
public Project $project;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-07-26 11:23:47 +00:00
|
|
|
public string $name = '';
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-07-26 11:23:47 +00:00
|
|
|
public string $description = '';
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-07-26 11:23:47 +00:00
|
|
|
protected $rules = [
|
|
|
|
'name' => 'required|string|min:3',
|
|
|
|
];
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2023-07-26 11:23:47 +00:00
|
|
|
protected $validationAttributes = [
|
|
|
|
'name' => 'Environment Name',
|
|
|
|
];
|
2023-08-08 09:51:36 +00:00
|
|
|
|
2023-07-26 11:23:47 +00:00
|
|
|
public function submit()
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
$this->validate();
|
|
|
|
$environment = Environment::create([
|
|
|
|
'name' => $this->name,
|
|
|
|
'project_id' => $this->project->id,
|
|
|
|
]);
|
|
|
|
|
2024-01-07 15:23:41 +00:00
|
|
|
return redirect()->route('project.resource.index', [
|
2023-07-26 11:23:47 +00:00
|
|
|
'project_uuid' => $this->project->uuid,
|
|
|
|
'environment_name' => $environment->name,
|
2023-12-27 15:45:01 +00:00
|
|
|
]);
|
2023-09-11 15:36:30 +00:00
|
|
|
} catch (\Throwable $e) {
|
2023-09-15 13:34:25 +00:00
|
|
|
handleError($e, $this);
|
2023-07-26 11:23:47 +00:00
|
|
|
} finally {
|
|
|
|
$this->name = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|