lasthourcloud/app/Livewire/Project/AddEnvironment.php

41 lines
980 B
PHP
Raw Normal View History

<?php
2023-12-07 18:06:32 +00:00
namespace App\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',
];
public function submit()
{
try {
$this->validate();
$environment = Environment::create([
'name' => $this->name,
'project_id' => $this->project->id,
]);
2023-12-27 15:45:01 +00:00
return redirect()->route('project.resources', [
'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) {
handleError($e, $this);
} finally {
$this->name = '';
}
}
}