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

36 lines
1018 B
PHP
Raw Normal View History

2023-05-05 07:28:00 +00:00
<?php
namespace App\Http\Livewire\Project\Application\EnvironmentVariable;
use App\Models\Application;
2023-05-05 12:20:10 +00:00
use App\Models\EnvironmentVariable;
2023-05-05 07:28:00 +00:00
use Livewire\Component;
class All extends Component
{
public Application $application;
2023-05-05 12:20:10 +00:00
protected $listeners = ['refreshEnvs', 'submit'];
2023-05-05 07:28:00 +00:00
public function refreshEnvs()
{
$this->application->refresh();
}
2023-05-05 12:20:10 +00:00
public function submit($data)
{
try {
EnvironmentVariable::create([
'key' => $data['key'],
'value' => $data['value'],
'is_build_time' => $data['is_build_time'],
2023-06-05 10:07:55 +00:00
'is_preview' => $data['is_preview'],
2023-05-05 12:20:10 +00:00
'application_id' => $this->application->id,
]);
$this->application->refresh();
2023-06-22 08:04:39 +00:00
$this->emit('success', 'Environment variable added successfully.');
2023-05-05 12:20:10 +00:00
$this->emit('clearAddEnv');
} catch (\Exception $e) {
2023-06-09 13:55:21 +00:00
return general_error_handler(err: $e, that: $this);
2023-05-05 12:20:10 +00:00
}
}
2023-05-05 07:28:00 +00:00
}