Right that makes better sense to me. Buyer/register and seller/register actions sound good to me.
Making 1 hybrid register with if this passing that variable just amounts to more work than it would be to make a function for each respective "User" Thanks for the code snips! K -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of cricket Sent: Monday, April 04, 2011 3:29 PM To: [email protected] Subject: Re: Place action where? On Sun, Apr 3, 2011 at 11:47 PM, Krissy Masters <[email protected]> wrote: > How should this be set up? > User can register as a Buyer or Seller each with different criteria needed > in the form so 2 forms. > Would you make 2 registration methods in the User controller > buyer_registration() and seller_registration(){} or a register in buyer > controller and register in seller controller? Each is a "User". I use entirely separate models for this sort of thing. There are various ways to approach extending models with Cake. I prefer to extend AppModel as normal and add User to the model's $belongsTo . Example: class Member extends AppModel { public $belongsTo = array( 'User' => array( 'className' => 'User', 'foreignKey' => 'user_id' ), 'Country', 'Region' ); class User extends AppModel { public $hasOne = array( 'Member' => array( 'className' => 'Member', 'foreignKey' => 'user_id', 'dependent' => true ), 'Affiliate' => array( 'className' => 'Affiliate', 'foreignKey' => 'user_id', 'dependent' => true ), ... The users table has model & foreign_key columns. Logging in: $model_name = $this->Auth->user('model'); $this->User->{$model_name}->recursive = -1; $model = $this->User->{$model_name}->read(null, $this->Auth->user('foreign_key')); $this->Session->write( "Auth.User.${model_name}", $model[$model_name] ); Then redirect based on model. You could have separate register actions in BuyersController & SellersController, or a single one in UsersController that takes a model name as a param. After ensuring the model exists, just do something like: $this->User->{$model}->set($this->data); if ($this->User->{$model}->validates()) { $this->data['User']['foreign_key'] = $this->User->{$model}->getInsertID(); ... -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/cake-php
