Welcome Guest, Not a member yet? Register   Sign In
Best practice for user and admin models?
#1

[eluser]bunal[/eluser]
Hi Coders,

What is the best practice for having methods related to same topic for users and admin in model?

For example: Category model
- Admin can create categories, update categories...
- User can subscribe into categories...

1. Have seperate models for user and admin? (category_user_model.php and category_admin_model.php)
2. Keep it in a modal and control with user level logic? (category_model.php)

What do you prefer mostly?

Thanks
#2

[eluser]bunal[/eluser]
Any thoughts?
#3

[eluser]Flemming[/eluser]
There's no good reason that I can think of for having a separate admin model - most methods (except add/edit/delete) will be used by both front-end and admin controllers. It's your controllers that you should be separating in my opinion.

You can apply some really excellent access control to your controllers with this ACL library from wiredesignz:

http://ellislab.com/forums/viewthread/111916

hope that helps you?
#4

[eluser]sl3dg3hamm3r[/eluser]
Hi

During my last project, I seperated strictly admin and normal user stuff. I even put these files into two different subfolders.
Within time I came to the conclusion that is sometimes not a very good solution, since among the seperated models there is sometimes the same or at least similar functionality (list products, e.g., would be on both sides needed). But uppon now I couldn't come up with a very elegant solution in order to share the common tasks. Maybe inheritance might become handy there - in a future project I will spend definitely more thoughts about such topics.

sl3dg3
#5

[eluser]bunal[/eluser]
Thanks for the answers and sharing your experiences




Theme © iAndrew 2016 - Forum software by © MyBB