lasthourcloud/app/Http/Livewire/Project/Application/EnvironmentVariable/Show.php

41 lines
1.0 KiB
PHP
Raw Normal View History

2023-05-04 20:29:14 +00:00
<?php
namespace App\Http\Livewire\Project\Application\EnvironmentVariable;
use App\Models\EnvironmentVariable as ModelsEnvironmentVariable;
use Livewire\Component;
2023-07-13 11:16:24 +00:00
use Visus\Cuid2\Cuid2;
2023-05-04 20:29:14 +00:00
class Show extends Component
{
public $parameters;
public ModelsEnvironmentVariable $env;
2023-07-13 11:16:24 +00:00
public string|null $modalId = null;
2023-05-04 20:29:14 +00:00
protected $rules = [
'env.key' => 'required|string',
'env.value' => 'required|string',
'env.is_build_time' => 'required|boolean',
];
2023-06-16 10:35:40 +00:00
protected $validationAttributes = [
'key' => 'key',
'value' => 'value',
'is_build_time' => 'build',
];
2023-05-04 20:29:14 +00:00
public function mount()
{
2023-07-13 11:16:24 +00:00
$this->modalId = new Cuid2(7);
2023-06-15 07:15:41 +00:00
$this->parameters = getRouteParameters();
2023-05-04 20:29:14 +00:00
}
public function submit()
{
$this->validate();
$this->env->save();
2023-06-22 08:04:39 +00:00
$this->emit('success', 'Environment variable updated successfully.');
2023-05-04 20:29:14 +00:00
}
public function delete()
{
$this->env->delete();
2023-05-05 07:28:00 +00:00
$this->emit('refreshEnvs');
2023-05-04 20:29:14 +00:00
}
}