/** * Model * */ class extends AppModel { /** * Use database config * * @var string */ public $useDbConfig = ''; /** * Primary key field * * @var string */ public $primaryKey = ''; /** * Display field * * @var string */ public $displayField = ''; /** * Behaviors * * @var array */ public $actsAs = array(); $validations): echo "\t\t'$field' => array(\n"; foreach ($validations as $key => $validator): echo "\t\t\t'$key' => array(\n"; echo "\t\t\t\t'rule' => array('$validator'),\n"; echo "\t\t\t\t//'message' => 'Your custom message here',\n"; echo "\t\t\t\t//'allowEmpty' => false,\n"; echo "\t\t\t\t//'required' => false,\n"; echo "\t\t\t\t//'last' => false, // Stop validation after this rule\n"; echo "\t\t\t\t//'on' => 'create', // Limit validation to 'create' or 'update' operations\n"; echo "\t\t\t),\n"; endforeach; echo "\t\t),\n"; endforeach; echo "\t);\n"; endif; foreach ($associations as $assoc): if (!empty($assoc)): ?> // The Associations below have been created with all possible keys, those that are not needed can be removed $relation): $out = "\n\t\t'{$relation['alias']}' => array(\n"; $out .= "\t\t\t'className' => '{$relation['className']}',\n"; $out .= "\t\t\t'foreignKey' => '{$relation['foreignKey']}',\n"; $out .= "\t\t\t'conditions' => '',\n"; $out .= "\t\t\t'fields' => '',\n"; $out .= "\t\t\t'order' => ''\n"; $out .= "\t\t)"; if ($i + 1 < $typeCount) { $out .= ","; } echo $out; endforeach; echo "\n\t);\n"; endif; endforeach; if (!empty($associations['hasMany'])): $belongsToCount = count($associations['hasMany']); echo "\n/**\n * hasMany associations\n *\n * @var array\n */"; echo "\n\tpublic \$hasMany = array("; foreach ($associations['hasMany'] as $i => $relation): $out = "\n\t\t'{$relation['alias']}' => array(\n"; $out .= "\t\t\t'className' => '{$relation['className']}',\n"; $out .= "\t\t\t'foreignKey' => '{$relation['foreignKey']}',\n"; $out .= "\t\t\t'dependent' => false,\n"; $out .= "\t\t\t'conditions' => '',\n"; $out .= "\t\t\t'fields' => '',\n"; $out .= "\t\t\t'order' => '',\n"; $out .= "\t\t\t'limit' => '',\n"; $out .= "\t\t\t'offset' => '',\n"; $out .= "\t\t\t'exclusive' => '',\n"; $out .= "\t\t\t'finderQuery' => '',\n"; $out .= "\t\t\t'counterQuery' => ''\n"; $out .= "\t\t)"; if ($i + 1 < $belongsToCount) { $out .= ","; } echo $out; endforeach; echo "\n\t);\n\n"; endif; if (!empty($associations['hasAndBelongsToMany'])): $habtmCount = count($associations['hasAndBelongsToMany']); echo "\n/**\n * hasAndBelongsToMany associations\n *\n * @var array\n */"; echo "\n\tpublic \$hasAndBelongsToMany = array("; foreach ($associations['hasAndBelongsToMany'] as $i => $relation): $out = "\n\t\t'{$relation['alias']}' => array(\n"; $out .= "\t\t\t'className' => '{$relation['className']}',\n"; $out .= "\t\t\t'joinTable' => '{$relation['joinTable']}',\n"; $out .= "\t\t\t'foreignKey' => '{$relation['foreignKey']}',\n"; $out .= "\t\t\t'associationForeignKey' => '{$relation['associationForeignKey']}',\n"; $out .= "\t\t\t'unique' => 'keepExisting',\n"; $out .= "\t\t\t'conditions' => '',\n"; $out .= "\t\t\t'fields' => '',\n"; $out .= "\t\t\t'order' => '',\n"; $out .= "\t\t\t'limit' => '',\n"; $out .= "\t\t\t'offset' => '',\n"; $out .= "\t\t\t'finderQuery' => '',\n"; $out .= "\t\t)"; if ($i + 1 < $habtmCount) { $out .= ","; } echo $out; endforeach; echo "\n\t);\n\n"; endif; ?> }