Skip to main content
Back to packages
322 GitHub stars

Climactic/laravel-credits

View on GitHub

Description

A ledger-based Laravel package for managing credit-based systems in your application.

🔧 Setup Your Model

Add the HasCredits trait to any model that should handle credits:

use Climactic\Credits\Traits\HasCredits;
 
class User extends Model
{
use HasCredits;
}

💳 Basic Usage

// Add credits
$user->creditAdd(100.00, 'Subscription Activated');
 
// Deduct credits
$user->creditDeduct(50.00, 'Purchase Made');
 
// Get current balance
$balance = $user->creditBalance();
 
// Check if user has enough credits
if ($user->hasCredits(30.00)) {
// Proceed with transaction
}

💸 Transfers

Transfer credits between two models:

$sender->creditTransfer($recipient, 100.00, 'Paying to user for their service');

Recent Courses on Laravel Daily

Laravel 13 Eloquent: Expert Level

41 lessons
1 h 34 min

Queues in Laravel 13

18 lessons
1 h 12 min read

How to Structure Laravel 13 Projects

16 lessons
1 h 32 min read