User Plans and roles Permissions Validating
Hello guys , I'm working on an application (building APIs ) where the user have plans (each plan has it's own features)
I have an owner of a market who has plan for this (storage,emails,etc..) , the market has roles and permissions for workers (create-show-edit,etc..)
I want to know what's the best way to validate the owner if he is able to perform a certain action or not with the minimum amount of querying
notice that I have to validate for each method if the user's Market has the right plan to do this action or not ! and then validate for the worker if he has the right permission to do that or not
I also use Entrust package for dealing with user roles and permission (permission for user is different from his plan )
my database design for System plans
##Plans Table | id | name | description
##Features Table | id | feature
##plan_features table | id | plan_id | feature_id
I'm validating the user by this
$features =$user->plan->features
and then checking if the action I want is in the returned collection or not.
I do this in every action which requires validating
but I see this approach as a bad practice to do in a big project and would like to decrease the no. of queries as possible
Please or to participate in this conversation.