wip
This commit is contained in:
88
app/Models/Ecommerce/Product/Order/Payment/OrderPayment.php
Normal file
88
app/Models/Ecommerce/Product/Order/Payment/OrderPayment.php
Normal file
@@ -0,0 +1,88 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user