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

maximaexchen's avatar

Best way to restict the amount of records a user with sepcific subscription plan can create

Hi everybody.

I have a subscription system with 4 plans. So plan1 subscribers should only be able to create 4 records of a model and so on...

I have spatie/laravel-permission in use and own subscription logic.

What would be the best way in your opinion. Roles and Permissions? Policy / Gate?

To do it directly in controller sounds not good to me. I am still learning, so any suggestion appreciated.

Thanks in advance. Regards Marcus

0 likes
4 replies
tykus's avatar

Maybe something in a Form Request's authorize method to check the number of existing records against a pre-determined maximum for their plan.

1 like
martinbean's avatar
Level 80

@maximaexchen If you’re using resourceful controllers then you should have a corresponding policy for the model the controller’s manipulating. In the create() method in the policy, you can then check if the user’s current plan allows creating an additional record.

2 likes
tykus's avatar

Yes, @martinbean is absolutely correct - authorization is not the place for this... stupid tykus... :facepalm:

Please or to participate in this conversation.