devworkout/laravel-user-limits

1.0.7 2019-08-08 21:31 UTC

This package is auto-updated.

Last update: 2024-04-30 00:45:24 UTC


README

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.