Merge branch 'ControlPanel-gg:development' into development

This commit is contained in:
IceToast 2023-02-05 16:37:18 +01:00 committed by GitHub
commit 3522dfe4c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 52 additions and 6 deletions

View file

@ -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("<fg=yellow>Notified user:</> <fg=blue>{$user->name}</>");

View file

@ -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;
}
}

View file

@ -18,10 +18,11 @@ class Kernel extends ConsoleKernel
{
$schedule->command('credits:charge')->hourly();
$schedule->command('cp:versioncheck:get')->daily();
$schedule->command('payments:open: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');
}

View file

@ -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,

View file

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

View file

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

View file

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

View file

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