Buyer Seller modelling problem

I am working on an application which has two types of entity - buyer and seller. I have to create a login and profile page for these entities. Login page is same for both of them but profile page has differnet attributes.

Should I create a separate model class for each one of them? Or should I create a User table for registration details and 2 separate classes for buyer and seller profiles extending from User model. Please guide me what would be the best way of keeping this type of data in Yii models.

Hi!

its not so simple to answer. what datas want you? How many different attributes are for buyer’s and seller’s? in the future u think will refactor, extend?

the best choice i think what u sad:

class UserModel extends CModel {

/** common attributes and methods

  • for example

  • id, name, email

*/

}

class Buyer extends UserModel {

//special datas

}

class Seller extends UserModel {

//special datas

}

The first question you need to address is - Can a user be a Buyer and a Seller? Or will you require separate accounts?

If the answer is no, a single User model with attribute indicating buyer vs. seller is adequate.

If course, your attribute could simply allow both. Example:

userclass (INT)

buyer=0

seller=1

both=2

You could also create multiple models. Just depends on what your needs are in terms of how you define a Buyer vs. a User and a Seller vs. a User… how many additional attributes are needed?