PHP code example of chapdel / laravel-credit

1. Go to this page and download the library: Download chapdel/laravel-credit library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

chapdel / laravel-credit example snippets


return [
    "initial" => 0
];


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;
}



$user = User::find(1);
$user->initCredits();



$user = User::find(1);
$user->addCredits(500);



$user = User::find(1);
$user->deductCredits(50);



$user = User::find(1);
$user->deductCredits(100);



$user = User::find(1);
$user->credit;

bash
php artisan vendor:publish --provider="Chapdel\Credit\CreditServiceProvider" --tag="laravel-credit-migrations"
php artisan migrate
bash
php artisan vendor:publish --provider="Chapdel\Credit\CreditServiceProvider" --tag="laravel-credit-config"