Skip to content

devworkout/laravel-user-limits

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel User Limits

This package abstracts and simplifies managing monthly service limits for users in your Laravel application.

Installation

You can install the package via composer:

composer require devworkout/laravel-user-limits

Add \DevWorkout\UserLimits\Models\HasLimits trait to User model:

    use HasLimits;

Add limits:refresh to your Console Kernel Schedule.

Usage

\DevWorkout\UserLimits\Limit::create([
    'subject' => 'domains',
    'allowed' => 3,
    'period' => 'permanent'
]);

\DevWorkout\UserLimits\Limit::create([
    'subject' => 'cards',
    'package' => 'pro',
    'allowed' => 100,
    'period' => 'monthly'
]);

echo auth()->user()->usage('cards')->allowed();
echo auth()->user()->usage('cards')->used();
echo auth()->user()->usage('cards')->remaining();

echo auth()->user()->usage('cards','pro')->exceeded();

echo auth()->user()->usage('cards')->reset();
echo auth()->user()->usage('cards')->increment();
echo auth()->user()->usage('domains')->decrement();

echo auth()->user()->usage('cards')->refreshed_at();
echo auth()->user()->usage('cards')->next_refresh_at();

Testing

composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email us instead of using the issue tracker.

Credits

Support us

Give us a star!

License

The MIT License (MIT). Please see License File for more information.

About

👷 Work in progress

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Languages