<?php
class User extends AppModel {

	var $name = 'User';
	var $primaryKey = 'id';
	var $useTable = 'users';
	
	
	var $validate = array(
			'email' => array( 
            	'notempty' => array(
 				'rule' => 'notEmpty',
				'message' => 'The Email field cannot be left blank'
 				),
             	'unique' => array( 
                	'rule' => array('checkUnique', 'email'), 
                	'message' => 'Email alread in use. Please Use another.' 
            	) 
          	),
			
          	'first_name'=>array('notempty' => array(
 				'rule' => 'notEmpty',
				'message' => 'Please provide your First Name'
 				)),
 				'last_name'=>array('notempty' => array(
 				'rule' => 'notEmpty',
				'message' => 'Please provide your Last Name'
 				)),
			'password'=> array( 
				 'notempty' => array(
 				'rule' => 'notEmpty',
				'message' => 'Password cannot be left blank'
 				)/*,
				 'passwordSimilar' => array( 
					'rule' => 'checkPasswords', 
					'message' => 'Your password does not match your confirmation password.' 
				)*/),
			 
			
		); 
	
	
	function checkPasswords($data){ 
          if($this->data['User']['password'] == $this->data['User']['confirm_password']){ 
             return true; }
          else{return false;}
      }
      
	function checkUnique($data, $fieldName) { 
            $valid = false; 
            if(isset($fieldName) && $this->hasField($fieldName)) { 
             $valid = $this->isUnique(array($fieldName => $data)); 
            } 
            return $valid; 
  	}
  	
  	
  	
  	
	
}
?>