coolify/app/Livewire/Project/Shared/EnvironmentVariable/Add.php

52 lines
1.2 KiB
PHP
Raw Normal View History

2023-05-04 22:29:14 +02:00
<?php
2023-12-07 19:06:32 +01:00
namespace App\Livewire\Project\Shared\EnvironmentVariable;
2023-05-04 22:29:14 +02:00
use Livewire\Component;
class Add extends Component
{
public $parameters;
2023-06-05 12:07:55 +02:00
public bool $is_preview = false;
2023-05-04 22:29:14 +02:00
public string $key;
2023-09-26 14:45:52 +02:00
public ?string $value = null;
2023-05-04 22:29:14 +02:00
public bool $is_build_time = false;
2023-05-05 14:20:10 +02:00
protected $listeners = ['clearAddEnv' => 'clear'];
2023-05-05 09:28:00 +02:00
protected $rules = [
'key' => 'required|string',
2023-09-26 14:45:52 +02:00
'value' => 'nullable',
2023-05-05 09:28:00 +02:00
'is_build_time' => 'required|boolean',
];
2023-06-16 12:35:40 +02:00
protected $validationAttributes = [
'key' => 'key',
'value' => 'value',
'is_build_time' => 'build',
];
2023-05-04 22:29:14 +02:00
public function mount()
{
$this->parameters = get_route_parameters();
2023-05-04 22:29:14 +02:00
}
2023-05-04 22:29:14 +02:00
public function submit()
{
2023-05-05 09:28:00 +02:00
$this->validate();
2023-09-26 14:45:52 +02:00
ray($this->key, $this->value, $this->is_build_time);
2023-12-07 19:06:32 +01:00
$this->dispatch('saveKey', [
2023-05-05 14:20:10 +02:00
'key' => $this->key,
'value' => $this->value,
'is_build_time' => $this->is_build_time,
2023-06-05 12:07:55 +02:00
'is_preview' => $this->is_preview,
2023-05-05 14:20:10 +02:00
]);
2023-07-13 13:16:24 +02:00
$this->clear();
2023-05-05 14:20:10 +02:00
}
2023-05-05 14:20:10 +02:00
public function clear()
{
$this->key = '';
$this->value = '';
$this->is_build_time = false;
2023-05-04 22:29:14 +02:00
}
}