From be633f05608781ecf5c666a6962a270b6f4bb48e Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Thu, 27 Jun 2024 15:07:41 +0200 Subject: [PATCH] fix: only run cloud clean on cloud + remove root team --- app/Console/Commands/CloudCleanupSubscriptions.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/app/Console/Commands/CloudCleanupSubscriptions.php b/app/Console/Commands/CloudCleanupSubscriptions.php index 0ef775dda..1d9dc5d74 100644 --- a/app/Console/Commands/CloudCleanupSubscriptions.php +++ b/app/Console/Commands/CloudCleanupSubscriptions.php @@ -14,13 +14,22 @@ class CloudCleanupSubs extends Command public function handle() { try { + if (! isCloud()) { + $this->error('This command can only be run on cloud'); + + return; + } ray()->clearAll(); $this->info('Cleaning up subcriptions teams'); $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) { - $this->info("Checking team {$team->id}"); + if ($team) { + $this->info("Checking team {$team->id}"); + } if (! data_get($team, 'subscription')) { $this->disableServers($team);