I'm working on an app which has a set of features. I want to restrict every feature based on the subscription package that the user opted.
For example:
Let's say i have three subscription types:
1) Bronze - Free User
2) Silver
3) Gold
And i have three features:
1) Create additional user accounts
2) Create a group
Now i want users with Silver and Gold to have access to feature 1. And only users with Gold subscription given access to feature 2.
What could be the best way to implement this in PHP and database (Mysql).
Thanks,
Sash
In MySQL you have the following tables: users, subscriptions, features, subscriptions_features, and users_subscriptions
users_subscriptions has two columns user_id and subscription_id subscriptions_features as two columns subscription_id and feature_id
With this structure you will know the user->subscriptions->features, then on any restricted pages you check if the user has the required subscriptions etc.
You could save a lot of time designing an application like this by using the Symfony2 framework because it is designed to enable you to build and scaffold a prototype of this sort of thing in minutes, once you get the hang of it. If you don't get a kick out of this quick tutorial, I'll eat my hat.