Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- App::uses('AppModel', 'Model');
- define('BASE_UPLOAD_DIR', ROOT . DS . APP_DIR);
- define('UPLOAD_DIR', DS . 'uploads' . DS . 'TicketAttachment' . DS . date('Y') . DS . date('m') . DS . date('d') . DS);
- /**
- * TicketAttachment Model
- *
- * @property TicketResponses $TicketResponses
- */
- class TicketAttachment extends AppModel {
- public $actsAs = array( // Uploader Plugin
- 'Upload.Upload' => array(
- 'filename' => array(
- 'fields' => array(
- 'dir' => 'location',
- 'size' => 'filesize'
- ),
- 'handleUploadedFileCallback' => 'moveFileTo'
- )
- )
- );
- /**
- * Validation rules
- *
- * @var array
- */
- public $validate = array(
- 'ticket_response_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
- ),
- ),
- # 'filename' => array(
- # 'notEmpty' => array(
- # 'rule' => array('notEmpty'),
- # //'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
- # ),
- # ),
- 'embedded' => array(
- 'boolean' => array(
- 'rule' => array('boolean'),
- //'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
- ),
- ),
- 'location' => array(
- 'notEmpty' => array(
- 'rule' => array('notEmpty'),
- //'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
- ),
- ),
- );
- //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(
- 'TicketResponse' => array(
- 'className' => 'TicketResponse',
- 'foreignKey' => 'ticket_response_id',
- 'conditions' => '',
- 'fields' => '',
- 'order' => ''
- )
- );
- public function moveFileTo($field, $filename, $destination){
- $this->log('Hello World moveFileTo!', 'debug');
- pr($field); pr($filename); pr($destination);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment