Maybe something in a Form Request's authorize method to check the number of existing records against a pre-determined maximum for their plan.
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
@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.
Please or to participate in this conversation.