Guest User

TicketAttachment Model Class

a guest
Oct 3rd, 2014
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.56 KB | None | 0 0
  1. <?php
  2. App::uses('AppModel', 'Model');
  3. define('BASE_UPLOAD_DIR', ROOT . DS . APP_DIR);
  4. define('UPLOAD_DIR', DS . 'uploads' . DS . 'TicketAttachment' . DS . date('Y') . DS . date('m') . DS . date('d') . DS);
  5. /**
  6.  * TicketAttachment Model
  7.  *
  8.  * @property TicketResponses $TicketResponses
  9.  */
  10. class TicketAttachment extends AppModel {
  11.  
  12.     public $actsAs = array( // Uploader Plugin
  13.         'Upload.Upload' => array(
  14.             'filename' => array(
  15.                 'fields' => array(
  16.                     'dir'  => 'location',
  17.                     'size' => 'filesize'
  18.                 ),
  19.                 'handleUploadedFileCallback' => 'moveFileTo'
  20.             )
  21.         )
  22.     );
  23.  
  24. /**
  25.  * Validation rules
  26.  *
  27.  * @var array
  28.  */
  29.     public $validate = array(
  30.         'ticket_response_id' => array(
  31.             'numeric' => array(
  32.                 'rule' => array('numeric'),
  33.                 //'message' => 'Your custom message here',
  34.                 //'allowEmpty' => false,
  35.                 //'required' => false,
  36.                 //'last' => false, // Stop validation after this rule
  37.                 //'on' => 'create', // Limit validation to 'create' or 'update' operations
  38.             ),
  39.         ),
  40. #       'filename' => array(
  41. #           'notEmpty' => array(
  42. #               'rule' => array('notEmpty'),
  43. #               //'message' => 'Your custom message here',
  44. #               //'allowEmpty' => false,
  45. #               //'required' => false,
  46. #               //'last' => false, // Stop validation after this rule
  47. #               //'on' => 'create', // Limit validation to 'create' or 'update' operations
  48. #           ),
  49. #       ),
  50.         'embedded' => array(
  51.             'boolean' => array(
  52.                 'rule' => array('boolean'),
  53.                 //'message' => 'Your custom message here',
  54.                 //'allowEmpty' => false,
  55.                 //'required' => false,
  56.                 //'last' => false, // Stop validation after this rule
  57.                 //'on' => 'create', // Limit validation to 'create' or 'update' operations
  58.             ),
  59.         ),
  60.         'location' => array(
  61.             'notEmpty' => array(
  62.                 'rule' => array('notEmpty'),
  63.                 //'message' => 'Your custom message here',
  64.                 //'allowEmpty' => false,
  65.                 //'required' => false,
  66.                 //'last' => false, // Stop validation after this rule
  67.                 //'on' => 'create', // Limit validation to 'create' or 'update' operations
  68.             ),
  69.         ),
  70.     );
  71.  
  72.     //The Associations below have been created with all possible keys, those that are not needed can be removed
  73.  
  74. /**
  75.  * belongsTo associations
  76.  *
  77.  * @var array
  78.  */
  79.     public $belongsTo = array(
  80.         'TicketResponse' => array(
  81.             'className' => 'TicketResponse',
  82.             'foreignKey' => 'ticket_response_id',
  83.             'conditions' => '',
  84.             'fields' => '',
  85.             'order' => ''
  86.         )
  87.     );
  88.    
  89.     public function moveFileTo($field, $filename, $destination){
  90.         $this->log('Hello World moveFileTo!', 'debug');
  91.         pr($field); pr($filename); pr($destination);
  92.     }
  93. }
Advertisement
Add Comment
Please, Sign In to add comment