coolify/app/Livewire/Server/Create.php

48 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2023-10-09 09:00:18 +00:00
<?php
2023-12-07 18:06:32 +00:00
namespace App\Livewire\Server;
2023-10-09 09:00:18 +00:00
2025-10-09 10:53:57 +00:00
use App\Models\CloudProviderToken;
2023-10-09 09:00:18 +00:00
use App\Models\PrivateKey;
2024-02-23 14:45:53 +00:00
use App\Models\Team;
2023-10-09 09:00:18 +00:00
use Livewire\Component;
class Create extends Component
{
public $private_keys = [];
2024-06-10 20:43:34 +00:00
public ?string $selectedType = null;
public ?string $selectedTokenUuid = null;
2023-10-09 09:00:18 +00:00
public bool $limit_reached = false;
2024-06-10 20:43:34 +00:00
2025-10-09 10:53:57 +00:00
public bool $has_hetzner_tokens = false;
public function mount(?string $selectedType = null, ?string $selectedTokenUuid = null): void
2023-10-09 09:00:18 +00:00
{
$this->selectedType = in_array($selectedType, ['hetzner', 'vultr', 'digital-ocean', 'manual'], true)
? $selectedType
: null;
$this->selectedTokenUuid = $this->selectedType && $this->selectedType !== 'manual' ? $selectedTokenUuid : null;
$this->private_keys = PrivateKey::ownedByCurrentTeamCached();
2024-06-10 20:43:34 +00:00
if (! isCloud()) {
2023-10-09 09:00:18 +00:00
$this->limit_reached = false;
2024-06-10 20:43:34 +00:00
2023-10-09 09:00:18 +00:00
return;
}
2024-02-23 14:45:53 +00:00
$this->limit_reached = Team::serverLimitReached();
2025-10-09 10:53:57 +00:00
// Check if user has Hetzner tokens
$this->has_hetzner_tokens = CloudProviderToken::ownedByCurrentTeam()
->where('provider', 'hetzner')
->exists();
2023-10-09 09:00:18 +00:00
}
2024-06-10 20:43:34 +00:00
2023-10-09 09:00:18 +00:00
public function render()
{
return view('livewire.server.create');
}
}