chapdel/laravel-credit

Model credits system for Laravel.

1.3.0 2021-11-05 12:17 UTC

This package is auto-updated.

Last update: 2024-12-05 19:07:26 UTC


README

Latest Version on Packagist GitHub Code Style Action Status Total Downloads

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.