2023-07-26 11:23:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Livewire\Project;
|
|
|
|
|
|
|
|
use App\Models\Environment;
|
|
|
|
use App\Models\Project;
|
|
|
|
use Livewire\Component;
|
|
|
|
|
|
|
|
class AddEnvironment extends Component
|
|
|
|
{
|
|
|
|
public Project $project;
|
|
|
|
public string $name = '';
|
|
|
|
public string $description = '';
|
|
|
|
protected $rules = [
|
|
|
|
'name' => 'required|string|min:3',
|
|
|
|
];
|
|
|
|
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,
|
|
|
|
]);
|
|
|
|
|
|
|
|
return redirect()->route('project.resources', [
|
|
|
|
'project_uuid' => $this->project->uuid,
|
|
|
|
'environment_name' => $environment->name,
|
|
|
|
]);
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
general_error_handler($e, $this);
|
|
|
|
} finally {
|
|
|
|
$this->name = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|