Models and Modules

I am developing an admin module for a Yii powered app. My question is regarding models that need to be accessed from both the main app and the admin module.

Should I be creating a separate model within the module, or should I use the same model? The reason I ask is that the model is to have slightly different methods in the admin. If I do create another model, how do I specify which model I want to use?

I think, a good model should definitely work in both places. If you have different methods for admin, maybe rethink your model methods and try to unify them.

I often use different models modules.

Usually the model in admin is called AdminTablename extends tableName.

Usually admin has some more safe attribute or some different permission. The estension allow to keep all common part of the module in one place.

You could use scenarios for that. I usually try to reuse as much code as possible. This is also a maintenance issue. If you add attributes, you’d have to touch 2 files later.

That makes sense to me. I’ll try it that way. Thanks.