diff --git a/README.md b/README.md index bdcdf6b..06410f8 100644 --- a/README.md +++ b/README.md @@ -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" ``` diff --git a/composer.json b/composer.json index 0ec19e1..7290e54 100644 --- a/composer.json +++ b/composer.json @@ -23,6 +23,7 @@ ], "require": { "php": "^8.2", + "021/laravel-wallet": "^8.2", "illuminate/support": "^10.0", "lunarphp/lunar": "^0.8" }, diff --git a/composer.lock b/composer.lock index 9e93be9..eb0c3f3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,124 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "721071caf4082d4d694da455432f4771", + "content-hash": "b8da4530a52fb4c8103d1e267de2da79", "packages": [ + { + "name": "021/laravel-wallet", + "version": "v8.2.6", + "source": { + "type": "git", + "url": "https://github.com/021-projects/laravel-wallet.git", + "reference": "c66401a1682fce12a2ca0577eead7d7562b73585" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/021-projects/laravel-wallet/zipball/c66401a1682fce12a2ca0577eead7d7562b73585", + "reference": "c66401a1682fce12a2ca0577eead7d7562b73585", + "shasum": "" + }, + "require": { + "021/safely-transaction": "^1.0.1", + "ext-bcmath": "*", + "laravel/framework": "^10.0|^11.0", + "php": "^8.1|^8.2|^8.3" + }, + "require-dev": { + "larastan/larastan": "^2.0", + "laravel/pint": "^1.13", + "orchestra/testbench": "^8.21|^9.0", + "phpunit/phpunit": "^10.5" + }, + "type": "package", + "extra": { + "laravel": { + "providers": [ + "O21\\LaravelWallet\\ServiceProvider" + ], + "dont-discover": [] + } + }, + "autoload": { + "files": [ + "src/helpers.php" + ], + "psr-4": { + "O21\\LaravelWallet\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "021", + "email": "devsellio@gmail.com", + "homepage": "https://021-projects.github.io/", + "role": "Developer" + } + ], + "description": "Reliable and flexible wallet system for Laravel", + "keywords": [ + "balance", + "deposit", + "finance", + "laravel", + "payment", + "payout", + "transactions", + "transfer", + "wallet", + "withdrawal" + ], + "support": { + "issues": "https://github.com/021-projects/laravel-wallet/issues", + "source": "https://github.com/021-projects/laravel-wallet/tree/v8.2.6" + }, + "time": "2024-03-17T08:41:53+00:00" + }, + { + "name": "021/safely-transaction", + "version": "v1.0.3", + "source": { + "type": "git", + "url": "https://github.com/021-projects/laravel-safely-transaction.git", + "reference": "3036089425805bc29f6da9b88dc16896ff67c400" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/021-projects/laravel-safely-transaction/zipball/3036089425805bc29f6da9b88dc16896ff67c400", + "reference": "3036089425805bc29f6da9b88dc16896ff67c400", + "shasum": "" + }, + "require": { + "illuminate/database": "^7.0|^8.0|^9.0|^10.0|^11.0", + "php": "^8.0|^8.1|^8.2" + }, + "require-dev": { + "phpunit/phpunit": "^9.5.10" + }, + "type": "library", + "autoload": { + "psr-4": { + "O21\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Helper class for locking record in database", + "keywords": [ + "framework", + "laravel" + ], + "support": { + "issues": "https://github.com/021-projects/laravel-safely-transaction/issues", + "source": "https://github.com/021-projects/laravel-safely-transaction/tree/v1.0.3" + }, + "time": "2024-02-22T19:29:46+00:00" + }, { "name": "barryvdh/laravel-dompdf", "version": "v2.1.1", diff --git a/config/wallet.php b/config/wallet.php new file mode 100644 index 0000000..f2d7440 --- /dev/null +++ b/config/wallet.php @@ -0,0 +1,38 @@ + '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, + ], +]; diff --git a/src/LunarRewardsServiceProvider.php b/src/LunarRewardsServiceProvider.php index 0fcb071..3995807 100644 --- a/src/LunarRewardsServiceProvider.php +++ b/src/LunarRewardsServiceProvider.php @@ -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'); } /** @@ -100,6 +104,11 @@ protected function registerConfig(): void "lunar-rewards.{$configFile}", ); } + + $this->mergeConfigFrom( + "{$this->root}/config/wallet.php", + 'wallet', + ); } /** diff --git a/tests/Stubs/Users/User.php b/tests/Stubs/Users/User.php index ba8b967..5ef02ab 100644 --- a/tests/Stubs/Users/User.php +++ b/tests/Stubs/Users/User.php @@ -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;