2024-01-23 16:13:23 +00:00
|
|
|
<?php
|
|
|
|
|
2024-04-26 12:59:03 +00:00
|
|
|
namespace App\Livewire\SharedVariables\Team;
|
2024-01-23 16:13:23 +00:00
|
|
|
|
|
|
|
use App\Models\Team;
|
|
|
|
use Livewire\Component;
|
|
|
|
|
2024-04-26 12:59:03 +00:00
|
|
|
class Index extends Component
|
2024-01-23 16:13:23 +00:00
|
|
|
{
|
|
|
|
public Team $team;
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-01-23 16:13:23 +00:00
|
|
|
protected $listeners = ['refreshEnvs' => '$refresh', 'saveKey' => 'saveKey'];
|
|
|
|
|
|
|
|
public function saveKey($data)
|
|
|
|
{
|
|
|
|
try {
|
2024-03-15 21:02:37 +00:00
|
|
|
$found = $this->team->environment_variables()->where('key', $data['key'])->first();
|
|
|
|
if ($found) {
|
|
|
|
throw new \Exception('Variable already exists.');
|
|
|
|
}
|
2024-01-23 16:13:23 +00:00
|
|
|
$this->team->environment_variables()->create([
|
|
|
|
'key' => $data['key'],
|
|
|
|
'value' => $data['value'],
|
2024-03-15 21:02:37 +00:00
|
|
|
'is_multiline' => $data['is_multiline'],
|
2024-04-15 10:46:22 +00:00
|
|
|
'is_literal' => $data['is_literal'],
|
2024-01-23 16:13:23 +00:00
|
|
|
'type' => 'team',
|
|
|
|
'team_id' => currentTeam()->id,
|
|
|
|
]);
|
|
|
|
$this->team->refresh();
|
|
|
|
} catch (\Throwable $e) {
|
|
|
|
return handleError($e, $this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function mount()
|
|
|
|
{
|
|
|
|
$this->team = currentTeam();
|
|
|
|
}
|
2024-06-10 20:43:34 +00:00
|
|
|
|
2024-01-23 16:13:23 +00:00
|
|
|
public function render()
|
|
|
|
{
|
2024-04-26 12:59:03 +00:00
|
|
|
return view('livewire.shared-variables.team.index');
|
2024-01-23 16:13:23 +00:00
|
|
|
}
|
|
|
|
}
|