chapdel / laravel-credit
Model credits system for Laravel.
Fund package maintenance!
chapdel
Requires
- php: ^8.0
- illuminate/contracts: ^8.37
- spatie/laravel-package-tools: ^1.4.3
Requires (Dev)
- nunomaduro/collision: ^5.3
- nunomaduro/larastan: ^1.0
- orchestra/testbench: ^6.15
- pestphp/pest: ^1.18
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.3
- spatie/laravel-ray: ^1.23
README
Installation
You can install the package via composer:
composer require chapdel/laravel-credit
You can publish and run the migrations with:
php artisan vendor:publish --provider="Chapdel\Credit\CreditServiceProvider" --tag="laravel-credit-migrations" php artisan migrate
You can publish the config file with:
php artisan vendor:publish --provider="Chapdel\Credit\CreditServiceProvider" --tag="laravel-credit-config"
This is the contents of the published config file:
return [ "initial" => 0 ];
Usage
Traits
use Illuminate\Notifications\Notifiable; use Illuminate\Contracts\Auth\MustVerifyEmail; use Illuminate\Foundation\Auth\User as Authenticatable; use Chapdel\Credits\Traits\HasCredits; class User extends Authenticatable { use HasCredits; }
Interactions
init credits
$user = User::find(1); $user->initCredits();
Add credits
$user = User::find(1); $user->addCredits(500);
Deducting credits
$user = User::find(1); $user->deductCredits(50);
Update credits
$user = User::find(1); $user->deductCredits(100);
Getting credits
$user = User::find(1); $user->credit;
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.