Doubts on designing CakePHP project
I'm pretty new to CakePHP, and I'm trying to figure out the bes开发者_JAVA技巧t solution for the app I wanna build: The tables of the database are basically this:
- Companies
- Product
- Users_of_companies
- Service
- Admins (all the administrators that are able to insert new companies,services and products)
The idea is to have a project where the companies will have their products. Each product will have (many) services related to it, so I created a middle table were I store the product_id, service_id, and company_id.
My problem is to figure out a solution to have an admin panel for ourselves and the permissions related to that (maybe admin 1 can insert new companies, but admin 2 is just able to see them), and another admin panel for the users of a company who will be able to do different stuff depending on their permissions (creating new users of a company or just seeing their products, for example).
I've read about the admin in CakePHP but I'm not really sure how could I approach in my case, and I would appreciate of any thoughts.
Best,
First, you need to think about your datamodel. To me, from what you say, it looks like it will be something like this:
- companies : haveMany : products
- companies : haveMany : users
- products : haveMany : companies ?? I don't know
- products : haveMany : services
- products : haveMany : services
- services : haveMany : products ?? I don't know.
It's probably best to draw your datamodel and pencil in the relationships. This way you'll be able to understand how it all fits together. You'll start to see where the 1:n and m:n relationships lie.
For the admin side of things, look at the Auth component. If you're feeling brave, also look at the Acl component. Acl will allow you to define which groups of users can perform which actions. My advice is to stay away from the Admin system - it's crude and will frustrate you later.
If you haven't done so already, do - or at least read - the Blog Tutorial - it'll introduce you to many essential concepts and is relatively quick and painless. The Acl tutorial is good too, but more advanced. Mark Story's Acl Tutorial is possibly a little easier to follow (I think he wrote the one in the manual).
精彩评论