fix: only run cloud clean on cloud + remove root team

This commit is contained in:
Andras Bacsai 2024-06-27 15:07:41 +02:00
parent 613e980267
commit be633f0560

View File

@ -14,13 +14,22 @@ class CloudCleanupSubs extends Command
public function handle() public function handle()
{ {
try { try {
if (! isCloud()) {
$this->error('This command can only be run on cloud');
return;
}
ray()->clearAll(); ray()->clearAll();
$this->info('Cleaning up subcriptions teams'); $this->info('Cleaning up subcriptions teams');
$stripe = new \Stripe\StripeClient(config('subscription.stripe_api_key')); $stripe = new \Stripe\StripeClient(config('subscription.stripe_api_key'));
$teams = Team::all()->sortBy('id'); $teams = Team::all()->filter(function ($team) {
return $team->id !== 0;
})->sortBy('id');
foreach ($teams as $team) { foreach ($teams as $team) {
if ($team) {
$this->info("Checking team {$team->id}"); $this->info("Checking team {$team->id}");
}
if (! data_get($team, 'subscription')) { if (! data_get($team, 'subscription')) {
$this->disableServers($team); $this->disableServers($team);