feat: custom server limit

This commit is contained in:
Andras Bacsai
2024-02-23 15:45:53 +01:00
parent 55dd1ab0a1
commit 297b314904
6 changed files with 58 additions and 13 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Livewire\Server;
use App\Models\PrivateKey;
use App\Models\Team;
use Livewire\Component;
class Create extends Component
@@ -16,11 +17,7 @@ class Create extends Component
$this->limit_reached = false;
return;
}
$team = currentTeam();
$servers = $team->servers->count();
['serverLimit' => $serverLimit] = $team->limits;
$this->limit_reached = $servers >= $serverLimit;
$this->limit_reached = Team::serverLimitReached();
}
public function render()
{

View File

@@ -5,6 +5,7 @@ namespace App\Livewire\Server\New;
use App\Enums\ProxyStatus;
use App\Enums\ProxyTypes;
use App\Models\Server;
use App\Models\Team;
use Livewire\Component;
class ByIp extends Component
@@ -76,6 +77,9 @@ class ByIp extends Component
if (is_null($this->private_key_id)) {
return $this->dispatch('error', 'You must select a private key');
}
if (Team::serverLimitReached()) {
return $this->dispatch('error', 'You have reached the server limit for your subscription.');
}
$payload = [
'name' => $this->name,
'description' => $this->description,