From 62358aec4ef8cfb28f4d6d7cb776237cd0af9921 Mon Sep 17 00:00:00 2001 From: IceToast Date: Thu, 2 Feb 2023 23:19:08 +0100 Subject: [PATCH 1/4] =?UTF-8?q?feat:=20=E2=9C=A8=20Add=20open=20payments?= =?UTF-8?q?=20cleanup=20to=20schedule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/ChargeCreditsCommand.php | 4 +- app/Console/Commands/CleanupPayments.php | 42 +++++++++++++++++++ app/Console/Kernel.php | 5 ++- 3 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 app/Console/Commands/CleanupPayments.php diff --git a/app/Console/Commands/ChargeCreditsCommand.php b/app/Console/Commands/ChargeCreditsCommand.php index e51bfdf9..145943c7 100644 --- a/app/Console/Commands/ChargeCreditsCommand.php +++ b/app/Console/Commands/ChargeCreditsCommand.php @@ -67,7 +67,7 @@ class ChargeCreditsCommand extends Command $server->suspend(); //add user to notify list - if (! in_array($user, $this->usersToNotify)) { + if (!in_array($user, $this->usersToNotify)) { array_push($this->usersToNotify, $user); } } catch (\Exception $exception) { @@ -85,7 +85,7 @@ class ChargeCreditsCommand extends Command */ public function notifyUsers() { - if (! empty($this->usersToNotify)) { + if (!empty($this->usersToNotify)) { /** @var User $user */ foreach ($this->usersToNotify as $user) { $this->line("Notified user: {$user->name}"); diff --git a/app/Console/Commands/CleanupPayments.php b/app/Console/Commands/CleanupPayments.php new file mode 100644 index 00000000..eca142a8 --- /dev/null +++ b/app/Console/Commands/CleanupPayments.php @@ -0,0 +1,42 @@ +where('updated_at', '<', now()->subHour())->delete(); + } catch (\Exception $e) { + $this->error('Could not delete payments: ' . $e->getMessage()); + return 1; + } + + $this->info('Successfully deleted all open payments'); + return Command::SUCCESS; + } +} diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index 5f081211..ac055581 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -18,10 +18,11 @@ class Kernel extends ConsoleKernel { $schedule->command('credits:charge')->hourly(); $schedule->command('cp:versioncheck:get')->daily(); + $schedule->command('payments:clear')->daily(); //log cronjob activity $schedule->call(function () { - Storage::disk('logs')->put('cron.log', 'Last activity from cronjobs - '.now()); + Storage::disk('logs')->put('cron.log', 'Last activity from cronjobs - ' . now()); })->everyMinute(); } @@ -32,7 +33,7 @@ class Kernel extends ConsoleKernel */ protected function commands() { - $this->load(__DIR__.'/Commands'); + $this->load(__DIR__ . '/Commands'); require base_path('routes/console.php'); } From 9d383600bcde5bcae7452272339c38b58caf492a Mon Sep 17 00:00:00 2001 From: IceToast Date: Thu, 2 Feb 2023 23:20:19 +0100 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Missing=20primary=20k?= =?UTF-8?q?ey=20on=20payments=20table?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Models/Payment.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Models/Payment.php b/app/Models/Payment.php index 04c32831..79352327 100644 --- a/app/Models/Payment.php +++ b/app/Models/Payment.php @@ -13,6 +13,7 @@ class Payment extends Model use HasFactory; public $incrementing = false; + protected $primaryKey = 'id'; /** * @var string[] From 0ffb7ccb654c4793b7868d53f78aa2cdfc078c37 Mon Sep 17 00:00:00 2001 From: IceToast Date: Thu, 2 Feb 2023 23:21:52 +0100 Subject: [PATCH 3/4] =?UTF-8?q?refactor:=20=F0=9F=9A=9A=20Rename=20Cleanup?= =?UTF-8?q?=20command?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/{CleanupPayments.php => CleanupOpenPayments.php} | 2 +- app/Console/Kernel.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename app/Console/Commands/{CleanupPayments.php => CleanupOpenPayments.php} (95%) diff --git a/app/Console/Commands/CleanupPayments.php b/app/Console/Commands/CleanupOpenPayments.php similarity index 95% rename from app/Console/Commands/CleanupPayments.php rename to app/Console/Commands/CleanupOpenPayments.php index eca142a8..31510b6a 100644 --- a/app/Console/Commands/CleanupPayments.php +++ b/app/Console/Commands/CleanupOpenPayments.php @@ -12,7 +12,7 @@ class CleanupPayments extends Command * * @var string */ - protected $signature = 'payments:clear'; + protected $signature = 'payments:open:clear'; /** * The console command description. diff --git a/app/Console/Kernel.php b/app/Console/Kernel.php index ac055581..28d1d36a 100644 --- a/app/Console/Kernel.php +++ b/app/Console/Kernel.php @@ -18,7 +18,7 @@ class Kernel extends ConsoleKernel { $schedule->command('credits:charge')->hourly(); $schedule->command('cp:versioncheck:get')->daily(); - $schedule->command('payments:clear')->daily(); + $schedule->command('payments:open:clear')->daily(); //log cronjob activity $schedule->call(function () { From e8efc743b2c10a33d23c5016b6e77c3ab24f0c22 Mon Sep 17 00:00:00 2001 From: 1day2die Date: Thu, 2 Feb 2023 23:44:13 +0100 Subject: [PATCH 4/4] Add Label for Position and Useful links on home --- app/Http/Controllers/HomeController.php | 2 +- themes/default/views/admin/usefullinks/create.blade.php | 1 + themes/default/views/admin/usefullinks/edit.blade.php | 1 + themes/default/views/home.blade.php | 2 +- 4 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 23b41bb0..5a511758 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -111,7 +111,7 @@ class HomeController extends Controller return view('home')->with([ 'usage' => $usage, 'credits' => $credits, - 'useful_links' => UsefulLink::where("position","like","%dashboard%")->get()->sortby("id"), + 'useful_links_dashboard' => UsefulLink::where("position","like","%dashboard%")->get()->sortby("id"), 'bg' => $bg, 'boxText' => $boxText, 'unit' => $unit, diff --git a/themes/default/views/admin/usefullinks/create.blade.php b/themes/default/views/admin/usefullinks/create.blade.php index b7174657..2c09571a 100644 --- a/themes/default/views/admin/usefullinks/create.blade.php +++ b/themes/default/views/admin/usefullinks/create.blade.php @@ -95,6 +95,7 @@
+ @foreach ($positions as $position) diff --git a/themes/default/views/home.blade.php b/themes/default/views/home.blade.php index 76c4e8e5..720e39aa 100644 --- a/themes/default/views/home.blade.php +++ b/themes/default/views/home.blade.php @@ -133,7 +133,7 @@
- @foreach ($useful_links as $useful_link) + @foreach ($useful_links_dashboard as $useful_link)