Skip to content

Instantly share code, notes, and snippets.

@sergiopvilar
Created September 12, 2011 02:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sergiopvilar/1210475 to your computer and use it in GitHub Desktop.
Save sergiopvilar/1210475 to your computer and use it in GitHub Desktop.
Models
<?php
class Publication extends AppModel {
var $name = 'Publication';
var $validate = array(
'uid' => array(
'notempty' => array(
'rule' => array('notempty'),
),
),
'account_id' => array(
'numeric' => array(
'rule' => array('numeric'),
),
),
'status' => array(
'numeric' => array(
'rule' => array('numeric'),
),
),
);
//The Associations below have been created with all possible keys, those that are not needed can be removed
var $belongsTo = array(
'Usuario' => array(
'className' => 'Usuario',
'foreignKey' => 'user_id',
'conditions' => '',
'fields' => '',
'order' => ''
),
'Account' => array(
'className' => 'Account',
'foreignKey' => 'account_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
}
<?php
class Usuario extends AppModel {
var $name = 'Usuario';
var $useTable = "usuarios";
var $validate = array(
'name' => array(
'notempty' => array(
'rule' => array('notempty'),
'message' => 'O seu nome não pode estar vazio',
),
),
'username' => array(
'notempty' => array(
'rule' => array('alphaNumeric'),
'message' => 'Seu nome de usuário só pode conter letras e números',
),
),
'password' => array(
'notempty' => array(
'rule' => array('notempty'),
'message' => 'Você precisa digitar uma senha',
),
),
'email' => array(
'email' => array(
'rule' => array('email'),
'message' => 'Insira um email válido',
),
'isUnique'=>array(
'rule' => 'isUnique',
'message' => 'Este email já está cadastrado'
),
),
'level' => array(
'notempty' => array(
'rule' => array('notempty'),
),
),
'active' => array(
'numeric' => array(
'rule' => array('numeric'),
),
),
'lastlogin' => array(
'date' => array(
'rule' => array('date'),
),
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment