Skip to main content
Back to packages
311 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

Testing in Laravel 13 For Beginners

26 lessons
1 h 41 min read

Queues in Laravel 13

18 lessons
1 h 12 min read

How to Structure Laravel 13 Projects

16 lessons
1 h 32 min read

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.