06.27 php saved
jmikola
Tags add more
 
Note
Inheriting model
  1. <?php
  2.  
  3. class Contact extends AppModel {
  4.    
  5.     var $name = 'Contact';
  6.    
  7.     var $belongsTo = array(
  8.         'Client' => array(
  9.             'className'  => 'Client',
  10.             'foreignKey' => 'client_id'
  11.         )
  12.     );
  13.    
  14.     var $hasMany = array(
  15.         'Greensheet' => array(
  16.             'className'  => 'Greensheet',
  17.             'foreignKey' => 'client_id',
  18.             'dependent'  => true
  19.         )
  20.     );
  21.    
  22.     var $validate = array(
  23.         'name' => array(
  24.             'unique' => array(
  25.                 'rule' => array('checkUnique', array('name', 'client_id')),
  26.                 'message' => 'Contact name already exists for this client',
  27.                 'required' => true
  28.             ),
  29.             'size' => array(
  30.                 'rule' => array('between', 1, 255),
  31.                 'message' => 'Contact name must be between 1 and 255 characters long',
  32.                 'required' => true
  33.             )
  34.         ),
  35.         'email' => array(
  36.             'rule' => 'email',
  37.             'message' => MSG_INVALID_EMAIL,
  38.             'allowEmpty' => true,
  39.             'required' => true
  40.         ),
  41.         'phone' => array(
  42.             'rule' => array('phone', null, 'us'),
  43.             'message' => MSG_INVALID_PHONE,
  44.             'allowEmpty' => true,
  45.             'required' => true
  46.         ),
  47.         'fax' => array(
  48.             'rule' => array('phone', null, 'us'),
  49.             'message' => MSG_INVALID_FAX,
  50.             'allowEmpty' => true,
  51.             'required' => true
  52.         )
  53.     );
  54.    
  55. }
  56.  
  57. ?>
Parsed in 0.145 seconds, using GeSHi 1.0.7.14

Modify this Paste