Prechádzať zdrojové kódy

Merge branch 'ControlPanel-gg:development' into development

IceToast 2 rokov pred
rodič
commit
3522dfe4c7

+ 2 - 2
app/Console/Commands/ChargeCreditsCommand.php

@@ -67,7 +67,7 @@ class ChargeCreditsCommand extends Command
                         $server->suspend();
                         $server->suspend();
 
 
                         //add user to notify list
                         //add user to notify list
-                        if (! in_array($user, $this->usersToNotify)) {
+                        if (!in_array($user, $this->usersToNotify)) {
                             array_push($this->usersToNotify, $user);
                             array_push($this->usersToNotify, $user);
                         }
                         }
                     } catch (\Exception $exception) {
                     } catch (\Exception $exception) {
@@ -85,7 +85,7 @@ class ChargeCreditsCommand extends Command
      */
      */
     public function notifyUsers()
     public function notifyUsers()
     {
     {
-        if (! empty($this->usersToNotify)) {
+        if (!empty($this->usersToNotify)) {
             /** @var User $user */
             /** @var User $user */
             foreach ($this->usersToNotify as $user) {
             foreach ($this->usersToNotify as $user) {
                 $this->line("<fg=yellow>Notified user:</> <fg=blue>{$user->name}</>");
                 $this->line("<fg=yellow>Notified user:</> <fg=blue>{$user->name}</>");

+ 42 - 0
app/Console/Commands/CleanupOpenPayments.php

@@ -0,0 +1,42 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Models\Payment;
+use Illuminate\Console\Command;
+
+class CleanupPayments extends Command
+{
+    /**
+     * The name and signature of the console command.
+     *
+     * @var string
+     */
+    protected $signature = 'payments:open:clear';
+
+    /**
+     * The console command description.
+     *
+     * @var string
+     */
+    protected $description = 'Clears all payments from the database that have state "open"';
+
+    /**
+     * Execute the console command.
+     *
+     * @return int
+     */
+    public function handle()
+    {
+        // delete all payments that have state "open" and are older than 1 hour
+        try {
+            Payment::where('status', 'open')->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;
+    }
+}

+ 3 - 2
app/Console/Kernel.php

@@ -18,10 +18,11 @@ class Kernel extends ConsoleKernel
     {
     {
         $schedule->command('credits:charge')->hourly();
         $schedule->command('credits:charge')->hourly();
         $schedule->command('cp:versioncheck:get')->daily();
         $schedule->command('cp:versioncheck:get')->daily();
+        $schedule->command('payments:open:clear')->daily();
 
 
         //log cronjob activity
         //log cronjob activity
         $schedule->call(function () {
         $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();
         })->everyMinute();
     }
     }
 
 
@@ -32,7 +33,7 @@ class Kernel extends ConsoleKernel
      */
      */
     protected function commands()
     protected function commands()
     {
     {
-        $this->load(__DIR__.'/Commands');
+        $this->load(__DIR__ . '/Commands');
 
 
         require base_path('routes/console.php');
         require base_path('routes/console.php');
     }
     }

+ 1 - 1
app/Http/Controllers/HomeController.php

@@ -111,7 +111,7 @@ class HomeController extends Controller
         return view('home')->with([
         return view('home')->with([
             'usage' => $usage,
             'usage' => $usage,
             'credits' => $credits,
             '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,
             'bg' => $bg,
             'boxText' => $boxText,
             'boxText' => $boxText,
             'unit' => $unit,
             'unit' => $unit,

+ 1 - 0
app/Models/Payment.php

@@ -13,6 +13,7 @@ class Payment extends Model
     use HasFactory;
     use HasFactory;
 
 
     public $incrementing = false;
     public $incrementing = false;
+    protected $primaryKey = 'id';
 
 
     /**
     /**
      * @var string[]
      * @var string[]

+ 1 - 0
themes/default/views/admin/usefullinks/create.blade.php

@@ -95,6 +95,7 @@
                                 </div>
                                 </div>
 
 
                                 <div class="form-group">
                                 <div class="form-group">
+                                    <label for="position">{{__('Position')}}</label>
                                     <select id="position" style="width:100%" class="custom-select" name="position[]"
                                     <select id="position" style="width:100%" class="custom-select" name="position[]"
                                             required multiple autocomplete="off" @error('position') is-invalid @enderror>
                                             required multiple autocomplete="off" @error('position') is-invalid @enderror>
                                         @foreach ($positions as $position)
                                         @foreach ($positions as $position)

+ 1 - 0
themes/default/views/admin/usefullinks/edit.blade.php

@@ -96,6 +96,7 @@
                                 </div>
                                 </div>
 
 
                                 <div class="form-group">
                                 <div class="form-group">
+                                    <label for="position">{{__('Position')}}</label>
                                     <select id="position" style="width:100%" class="custom-select" name="position[]"
                                     <select id="position" style="width:100%" class="custom-select" name="position[]"
                                             required multiple autocomplete="off" @error('position') is-invalid @enderror>
                                             required multiple autocomplete="off" @error('position') is-invalid @enderror>
                                         @foreach ($positions as $position)
                                         @foreach ($positions as $position)

+ 1 - 1
themes/default/views/home.blade.php

@@ -133,7 +133,7 @@
                     </div>
                     </div>
                     <!-- /.card-header -->
                     <!-- /.card-header -->
                     <div class="card-body">
                     <div class="card-body">
-                        @foreach ($useful_links as $useful_link)
+                        @foreach ($useful_links_dashboard as $useful_link)
                             <div class="alert alert-dismissible">
                             <div class="alert alert-dismissible">
                                 <button type="button" class="close" data-dismiss="alert"
                                 <button type="button" class="close" data-dismiss="alert"
                                     aria-hidden="true">×</button>
                                     aria-hidden="true">×</button>