Files
backend-mm/app/Models/Ecommerce/Product/Order/Payment/OrderPayment.php
2025-09-25 03:03:31 +05:00

89 lines
1.7 KiB
PHP

<?php
namespace App\Models\Ecommerce\Product\Order\Payment;
use App\Models\System\Settings\Payments\PaymentType;
use App\Repositories\System\Cache\CacheRepository;
class OrderPayment
{
/**
* Cash
*/
public const CASH = 'cash';
/**
* ATM
*/
public const ATM = 'atm';
/**
* Online (halkbank)
*/
public const ONLINE = 'online';
/**
* Online (halkbank)
*/
public const HALK_BANK = 'halk_bank';
/**
* Online (senagat)
*/
public const SENAGAT_BANK = 'senegat_bank';
/**
* Online (rysgal)
*/
public const RYSGAL_BANK = 'rysgal_bank';
/**
* Online (wneshka)
*/
public const WNESHKA_BANK = 'wneshka_bank';
/**
* Default payment value
*/
public static function default(): ?string
{
return CacheRepository::make(
name: 'cs-nova-models-default-order-payment',
value: fn () => PaymentType::where('code', 'cash')->pluck('id')->first(),
time: 60 * 60 * 24
);
}
/**
* Payment values
*/
public static function values(): array
{
return CacheRepository::make(
name: 'cs-nova-models-order-payments',
value: fn () => PaymentType::pluck('name', 'id')->toArray()
);
}
/**
* Old but good types
*
* @return array<int, string>
*/
public static function oldButGoodTypes(): array
{
return [
static::ATM => __('ATM'),
static::CASH => __('Cash'),
];
}
/**
* Formatted payment type for given "type"
*/
public static function formattedPaymentTypeFor(string $type): string
{
return static::values()[$type] ?? self::CASH;
}
}