Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

geetpurwar's avatar

Laravel Spark : Assign Quota

Hi,

I am creating a Image Generation App, where a user have specific quota (1000 units) after subscribing to specific plan. I need suggestions of how to approach this?

Example: Step 1 : User signed up Step 2 : user subscribes to a subscription plan Step 3 : User is assigned specific quota every month based on selected plan Step 4 : Quota reset at the month end or may be even. receive rollovers.

let me know how do you suggest to approach this.

0 likes
1 reply
Braunson's avatar

You could...

Set the quote on the plan (if it's different per plan) in the features area or a separate config file that matches plan_id -> quota limit.

  1. In area of action/logic where the quota would be used: create a check if the user's quota_used number is less then to their plan_id's quota set in the config/plan features/etc.
  2. In the same area of action/logic where the quota would be used, under the above check, add logic to increment the users quota used $user->quota_used
  3. Create a scheduled task that runs every month on the 1st first thing in the morning or end of the month at midnight to reset the quota_used for the users. It would loop through the currently active users, and reset them the quota_used number to 0.

Please or to participate in this conversation.