Skip to content

Commit

Permalink
add laravel wallet package for managing reward points
Browse files Browse the repository at this point in the history
  • Loading branch information
repl6669 committed Apr 5, 2024
1 parent 11459e8 commit 9aa54ad
Show file tree
Hide file tree
Showing 6 changed files with 169 additions and 4 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ composer require dystcz/lunar-rewards

Publish config files

> You will probably need them pretty bad
```bash
php artisan vendor:publish --provider="Dystcz\LunarRewards\LunarRewardsServiceProvider" --tag="lunar-rewards"
```
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
],
"require": {
"php": "^8.2",
"021/laravel-wallet": "^8.2",
"illuminate/support": "^10.0",
"lunarphp/lunar": "^0.8"
},
Expand Down
118 changes: 117 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions config/wallet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

return [
'default_currency' => 'LRP',

'balance' => [
'accounting_statuses' => [
\O21\LaravelWallet\Enums\TransactionStatus::SUCCESS,
\O21\LaravelWallet\Enums\TransactionStatus::ON_HOLD,
],
'extra_values' => [
// enable value_pending calculation
'pending' => false,
// enable value_on_hold calculation
'on_hold' => false,
],
'max_scale' => 8,
'log_states' => false,
],

'models' => [
'balance' => \O21\LaravelWallet\Models\Balance::class,
'balance_state' => \O21\LaravelWallet\Models\BalanceState::class,
'transaction' => \O21\LaravelWallet\Models\Transaction::class,
],

'table_names' => [
'balances' => 'lunar_rewards_balances',
'balance_states' => 'lunar_rewards_balance_states',
'transactions' => 'lunar_rewards_transactions',
],

'processors' => [
'deposit' => \O21\LaravelWallet\Transaction\Processors\DepositProcessor::class,
'charge' => \O21\LaravelWallet\Transaction\Processors\ChargeProcessor::class,
'transfer' => \O21\LaravelWallet\Transaction\Processors\TransferProcessor::class,
],
];
9 changes: 9 additions & 0 deletions src/LunarRewardsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ protected function publishConfig(): void
"{$this->root}/config/{$configFile}.php" => config_path("lunar-rewards/{$configFile}.php"),
], 'lunar-rewards');
}

$this->publishes([
"{$this->root}/config/wallet.php" => config_path('wallet.php'),
], 'wallet');
}

/**
Expand All @@ -100,6 +104,11 @@ protected function registerConfig(): void
"lunar-rewards.{$configFile}",
);
}

$this->mergeConfigFrom(
"{$this->root}/config/wallet.php",
'wallet',
);
}

/**
Expand Down
5 changes: 4 additions & 1 deletion tests/Stubs/Users/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,12 @@
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Lunar\Base\Traits\LunarUser;
use O21\LaravelWallet\Contracts\Payable;
use O21\LaravelWallet\Models\Concerns\HasBalance;

class User extends Authenticatable
class User extends Authenticatable implements Payable
{
use HasBalance;
use HasFactory;
use LunarUser;
use Notifiable;
Expand Down

0 comments on commit 9aa54ad

Please sign in to comment.