Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions app/Console/Commands/MakeUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

use App\Classes\PterodactylClient;
use App\Models\User;
use App\Settings\UserSettings;
use App\Settings\GeneralSettings;
use App\Settings\PterodactylSettings;
use App\Traits\Referral;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use App\Facades\Currency;

class MakeUserCommand extends Command
{
use Referral;
Expand Down Expand Up @@ -47,7 +47,7 @@ public function __construct()
*
* @return int
*/
public function handle(PterodactylSettings $ptero_settings, UserSettings $user_settings)
public function handle(PterodactylSettings $ptero_settings, GeneralSettings $general_settings)
{
$this->pterodactyl = new PterodactylClient($ptero_settings);
$ptero_id = $this->option('ptero_id') ?? $this->ask('Please specify your Pterodactyl ID.');
Expand Down Expand Up @@ -98,8 +98,8 @@ public function handle(PterodactylSettings $ptero_settings, UserSettings $user_s
'name' => $response['first_name'],
'email' => $response['email'],
'password' => Hash::make($password),
'credits' => $user_settings->initial_credits,
'server_limit' => $user_settings->initial_server_limit,
'credits' => $general_settings->initial_credits,
'server_limit' => $general_settings->initial_server_limit,
'referral_code' => $this->createReferralCode(),
'pterodactyl_id' => $response['id'],
]);
Expand Down
216 changes: 0 additions & 216 deletions app/Console/Commands/NotifyServerSuspension.php

This file was deleted.

2 changes: 0 additions & 2 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class Kernel extends ConsoleKernel
protected $commands = [
Commands\ChargeServers::class,
Commands\DeleteExpiredCoupons::class,
Commands\NotifyServerSuspension::class,
];

/**
Expand All @@ -28,7 +27,6 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
$schedule->command('servers:charge')->everyMinute();
$schedule->command('servers:notify-suspension')->daily();
$schedule->command('cp:versioncheck:get')->daily();
$schedule->command('payments:open:clear')->daily();
$schedule->command('coupons:delete')->daily();
Expand Down
7 changes: 2 additions & 5 deletions app/Events/CouponUsedEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Events;

use App\Models\Coupon;
use App\Models\User;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;
Expand All @@ -12,20 +11,18 @@ class CouponUsedEvent
{
use Dispatchable, InteractsWithSockets, SerializesModels;


public Coupon $coupon;
public string $couponCode;
public ?User $user = null;

/**
* Create a new event instance.
*
* @return void
*/
public function __construct(string $couponCode, ?User $user = null)
public function __construct(string $couponCode)
{

$this->couponCode = $couponCode;
$this->coupon = Coupon::where('code', $couponCode)->first();
$this->user = $user;
}
}
65 changes: 4 additions & 61 deletions app/Helpers/CurrencyHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,9 @@ private function convertForDisplay($amount)
return $amount / 1000;
}

/**
* Gets the effective locale to use for formatting, considering global overrides.
*
* @param string|null $locale The requested locale
* @param bool $ignoreOverride Whether to ignore the global override setting
* @return string The effective locale to use
*/
private function getEffectiveLocale($locale = null, $ignoreOverride = false)
public function formatForDisplay($amount, $decimals = 2)
{
$effectiveLocale = $locale ?: str_replace('_', '-', app()->getLocale());

if (!$ignoreOverride) {
$override = resolve(\App\Settings\GeneralSettings::class)->currency_format_override ?? null;
if ($override) {
$effectiveLocale = $override;
}
}

return $effectiveLocale;
}

/**
* Formats a currency amount for display.
*
* @param mixed $amount The amount to format.
* @param int $decimals Number of decimal places to use.
* @param string|null $locale The locale to use for formatting (defaults to current application locale).
* @param bool $ignoreOverride When true, bypasses the global currency format override setting.
* @return string The formatted currency string.
*/
public function formatForDisplay($amount, $decimals = 2, $locale = null, $ignoreOverride = false)
{
$locale = $this->getEffectiveLocale($locale, $ignoreOverride);

$display = $this->convertForDisplay($amount);

// For Bulgarian ('bg'), Spanish ('es'), and Polish ('pl') locales: For numbers <= 9999, use comma as decimal separator and no thousands separator.
// This follows common formatting conventions for small numbers in these locales, as per CLDR and local usage.
// source: https://forum.opencart.com/viewtopic.php?t=144907
$specialLocales = ['bg', 'es', 'pl'];
if (in_array($locale, $specialLocales, true) && $display <= 9999) {
return number_format($display, $decimals, ',', '');
}
$formatter = new NumberFormatter($locale, NumberFormatter::DECIMAL);
$formatter->setAttribute(NumberFormatter::MIN_FRACTION_DIGITS, $decimals);
$formatter->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, $decimals);
return $formatter->format($display);
return number_format($this->convertForDisplay($amount), $decimals, ',', '.');
}

public function formatForForm($amount, $decimals = 2)
Expand All @@ -70,25 +26,12 @@ public function prepareForDatabase($amount)
return (int)($amount * 1000);
}

public function formatToCurrency(int $amount, $currency_code, $locale = null)
public function formatToCurrency(int $amount, $currency_code, $locale = null,)
{
$locale = $this->getEffectiveLocale($locale, false);
$locale = $locale ?: str_replace('_', '-', app()->getLocale());

$formatter = new NumberFormatter($locale, NumberFormatter::CURRENCY);

return $formatter->formatCurrency($this->convertForDisplay($amount), $currency_code);
}

/**
* Formats the given amount for use in commands.
*
* Converts the amount from the smallest currency unit to a float.
*
* @param int $amount Amount in the smallest currency unit (e.g., thousandths).
* @return float Converted amount for commands.
*/
public function formatForCommands($amount)
{
return $this->convertForDisplay($amount);
}
}
Loading