<?php
App::uses('AppModel', 'Model');
/**
* Applicant Model
*
* @property StatusType $StatusType
* @property ApplicantComment $ApplicantComment
*/
class Applicant extends AppModel
{
/**
* Display field
*
* @var string
*/
public $displayField = 'firstname';
public $virtualFields = array(
'fullname' => "CONCAT(Applicant.firstname, ' ', Applicant.lastname)"
);
/**
* Validation rules
*
* @var array
*/
public $validate = array(
'firstname' => array(
'notBlank' => array(
'rule' => array('notBlank'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'lastname' => array(
'notBlank' => array(
'rule' => array('notBlank'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'email' => array(
'notBlank' => array(
'rule' => array('notBlank'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
'email' => array(
'rule' => array('email'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
'isUnique' => array(
'rule' => array('isUnique'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'status_type_id' => array(
'numeric' => array(
'rule' => array('numeric'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'category_id' => array(
'numeric' => array(
'rule' => array('numeric'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'file_number' => array(
'notBlank' => array(
'rule' => array('notBlank'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
'isUnique' => array(
'rule' => array('isUnique'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'token' => array(
'notBlank' => array(
'rule' => array('notBlank'),
//'message' => 'Your custom message here',
//'allowEmpty' => false,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
// Validation on other field name
'filenumber' => array(
'notBlank' => array(
'rule' => array('notBlank'),
'message' => 'Please provide File Number'
)
),
'secretkey' => array(
'notBlank' => array(
'rule' => array('notBlank'),
'message' => 'Please provide Secret Key'
)
),
'fee' => array(
'numeric' => array(
'rule' => array('numeric'),
'message' => 'Please enter number.',
'allowEmpty' => true,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'vendor_fee' => array(
'numeric' => array(
'rule' => array('numeric'),
'message' => 'Please enter number.',
'allowEmpty' => true,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
'agent_fee' => array(
'numeric' => array(
'rule' => array('numeric'),
'message' => 'Please enter number.',
'allowEmpty' => true,
//'required' => false,
//'last' => false, // Stop validation after this rule
//'on' => 'create', // Limit validation to 'create' or 'update' operations
),
),
);
// The Associations below have been created with all possible keys, those that are not needed can be removed
/**
* belongsTo associations
*
* @var array
*/
public $belongsTo = array(
'StatusType' => array(
'className' => 'StatusType',
'foreignKey' => 'status_type_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Vendor' => array(
'className' => 'Vendor',
'foreignKey' => 'vendor_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'User' => array(
'className' => 'User',
'foreignKey' => 'agent_user_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Category' => array(
'className' => 'Category',
'foreignKey' => 'category_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
public $hasOne = array(
'VendorApplicantFee' => array(
'className' => 'VendorApplicantFee',
'foreignKey' => 'applicant_id',
'dependent' => true
)
);
public $hasMany = array(
'ApplicantComment' => array(
'className' => 'ApplicantComment',
'foreignKey' => 'applicant_id',
'dependent' => true,
'conditions' => '',
'fields' => '',
'order' => 'created DESC',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'AmountTransaction' => array(
'className' => 'AmountTransaction',
'foreignKey' => 'applicant_id',
'dependent' => true,
'conditions' => '',
'fields' => '',
'order' => 'id DESC',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'AmountTransactionsCashToBanks' => array(
'className' => 'AmountTransactionsCashToBanks',
'foreignKey' => 'applicant_id',
'dependent' => true,
'conditions' => '',
'fields' => '',
'order' => 'id DESC',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'Message' => array(
'className' => 'Message',
'foreignKey' => 'applicant_id',
'dependent' => true,
'conditions' => '',
'fields' => '',
'order' => 'id DESC',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
'Invoice' => array(
'className' => 'Invoice',
'foreignKey' => 'applicant_id',
'dependent' => true,
'conditions' => '',
'fields' => '',
'order' => 'id DESC',
'limit' => '',
'offset' => '',
'exclusive' => '',
'finderQuery' => '',
'counterQuery' => ''
),
);
function beforeFind($query)
{
//$query['conditions'] += array('Applicant.is_deleted' => 0);
return parent::beforeFind($query); // TODO: Change the autogenerated stub
}
}