2023-08-14 13:22:29 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Models\PrivateKey;
|
|
|
|
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
|
|
|
use Illuminate\Foundation\Validation\ValidatesRequests;
|
|
|
|
|
|
|
|
class ServerController extends Controller
|
|
|
|
{
|
|
|
|
use AuthorizesRequests, ValidatesRequests;
|
|
|
|
|
|
|
|
public function new_server()
|
|
|
|
{
|
2023-08-14 13:25:03 +00:00
|
|
|
if (!is_cloud()) {
|
|
|
|
return view('server.create', [
|
|
|
|
'limit_reached' => false,
|
|
|
|
'private_keys' => PrivateKey::ownedByCurrentTeam()->get(),
|
|
|
|
]);
|
|
|
|
}
|
2023-08-14 13:22:29 +00:00
|
|
|
$servers = auth()->user()->currentTeam()->servers->count();
|
2023-08-14 13:25:03 +00:00
|
|
|
$subscription = auth()->user()->currentTeam()?->subscription->type();
|
2023-08-14 13:22:29 +00:00
|
|
|
$limits = config('constants.limits.server')[strtolower($subscription)];
|
|
|
|
$limit_reached = true ?? $servers >= $limits[$subscription];
|
2023-08-14 13:25:03 +00:00
|
|
|
|
2023-08-14 13:22:29 +00:00
|
|
|
return view('server.create', [
|
|
|
|
'limit_reached' => $limit_reached,
|
|
|
|
'private_keys' => PrivateKey::ownedByCurrentTeam()->get(),
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
}
|