<?php
class Item extends AppModel {

  var $name = 'Item';

  var $validate = array(
    'name' => array(
      'unique' => array(
        'rule' => array('isUnique'),
        'on' => 'create',
        'message' => 'その識別名は既に登録されています。'
      ),
      'alphaNumeric' => array(
        'rule' => array('custom', '/^[!-~]+$/'),
        'message' => '識別名は半角英数字のみ有効です。'
      ),
      'required' => array(
        'rule' => VALID_NOT_EMPTY,
        'allowEmpty' => false,
        'required' => true,
        'message' => '識別名を入力してください。'
      )
    ),
    'title' => array(
      'required' => array(
        'rule' => VALID_NOT_EMPTY,
        'allowEmpty' => false,
        'required' => true,
        'message' => '項目名を入力してください。'
      )
    ),
    'sort_order' => array(
      'numeric' => array(
        'rule' => array('numeric'),
        'message' => '並び順は半角数字のみ有効です。'
      )
    )
  );

  var $belongsTo = array(
    'ItemType' => array(
      'className' => 'ItemType',
      'foreignKey' => 'item_type_id',
      'conditions' => '',
      'fields' => '',
      'order' => ''
    )
  );

  var $hasMany = array(
    'ArticleItem' => array(
      'className' => 'ArticleItem',
      'foreignKey' => 'item_id',
      'dependent' => true,
      'conditions' => '',
      'fields' => '',
      'order' => '',
      'limit' => '',
      'offset' => '',
      'exclusive' => '',
      'finderQuery' => '',
      'counterQuery' => ''
    )
  );

}
?>