Thursday, August 30, 2012

Database Setup Help / Relations

I need to build a dual sided / role related site so there are 2 types of Users (Buyer and Seller) so upon registration User will select who they are and based on that create the User.

They can only be one or the other.

So when logged in as Buyer the can access the buyer end of the site, same as Seller.

 

But the issues I see come because the Seller / Buyer have different relations to other models. Is it better off to create the Buyer / Seller as separate MVC objects?

 

Something like this for User model?

 

                public $belongsTo = array(

                                'Role' => array(

                                                'className' => 'Role',

                                                'foreignKey' => 'role_id',

                                                'conditions' => '',

                                                'fields' => '',

                                                'order' => ''

                                )

                );

 

                public $hasOne = array(

                                'Buyer' => array(

                                                'className' => 'Buyer',

                                                'foreignKey' => 'user_id',

                                ),

                                'Seller' => array(

                                                'className' => 'Seller',

                                                'foreignKey' => 'user_id',

                                )

                );

               

               

Open to the hearing best solution to this issue from the community.

 

Thanks.

No comments: