49 lines
1.5 KiB
PHP
49 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace App\Helpers\FirstParty\Credits;
|
|
|
|
use App\Models\UserCredit;
|
|
|
|
class CreditsService
|
|
{
|
|
public static function depositSubscription(int $userId, int $amount, ?string $description = null): bool
|
|
{
|
|
return CreditsHelper::deposit($userId, $amount, UserCredit::TYPE_SUBSCRIPTION, $description);
|
|
}
|
|
|
|
public static function depositAlacarte(int $userId, int $amount, ?string $description = null): bool
|
|
{
|
|
return CreditsHelper::deposit($userId, $amount, UserCredit::TYPE_ALACARTE, $description);
|
|
}
|
|
|
|
public static function spend(int $userId, int $amount, ?string $description = null, ?bool $overrideSubscriptionFirst = null): bool
|
|
{
|
|
return CreditsHelper::spend($userId, $amount, $description, $overrideSubscriptionFirst);
|
|
}
|
|
|
|
public static function setSpendSubscriptionFirst(int $userId, bool $spendSubscriptionFirst): bool
|
|
{
|
|
return CreditsHelper::setSpendSubscriptionFirst($userId, $spendSubscriptionFirst);
|
|
}
|
|
|
|
public static function balance(int $userId, ?string $type = null): int
|
|
{
|
|
return CreditsHelper::balance($userId, $type);
|
|
}
|
|
|
|
public static function canSpend(int $userId, int $amount): bool
|
|
{
|
|
return CreditsHelper::canSpend($userId, $amount);
|
|
}
|
|
|
|
public static function summary(int $userId): array
|
|
{
|
|
return CreditsHelper::summary($userId);
|
|
}
|
|
|
|
public static function transactionHistory(int $userId, int $limit = 20): \Illuminate\Database\Eloquent\Collection
|
|
{
|
|
return CreditsHelper::transactionHistory($userId, $limit);
|
|
}
|
|
}
|