Video
Description
Track, limit, & restrict usages of users, accounts, or any other model.
Basic Usage
First, you need to use the HasLimits trait on your model.
use NabilHassen\LaravelUsageLimiter\Traits\HasLimits; class User extends Authenticatable{ use HasLimits;}
Create your Limits
# On standard plan 5 projects are allowed per month$projectsStandardLimit = Limit::create([ 'name' => 'projects', 'allowed_amount' => 5, 'plan' => 'standard', // optional 'reset_frequency' => 'every month' // optional]); # On pro plan 10 projects are allowed per month$projectsProLimit = Limit::create([ 'name' => 'projects', 'allowed_amount' => 10, 'plan' => 'pro', // optional 'reset_frequency' => 'every month' // optional]); # Increment projects limit on standard plan from 5 to 15 per month$projectsStandardLimit->incrementBy(10); # Decrement projects limit on pro plan from 10 to 7 per month$projectsProLimit->decrementBy(3);
Related Content on Laravel Daily
Video
Recent Courses on Laravel Daily
[NEW] Practical Laravel Security: Packages, Secrets, Supply-Chain Attacks
7 lessons
43 min read
Next.js Basics for Laravel Developers
11 lessons
58 min
How to Structure Laravel 13 Projects
16 lessons
1 h 32 min read