Skip to content

Instantly share code, notes, and snippets.

@hugofabricio
Last active January 4, 2016 04:09
Show Gist options
  • Select an option

  • Save hugofabricio/8566629 to your computer and use it in GitHub Desktop.

Select an option

Save hugofabricio/8566629 to your computer and use it in GitHub Desktop.
<?php
/**
* UserModel
*/
App::uses('AppModel', 'Model');
class User extends AppModel {
/**
* Configurações
*/
public $actsAs = array(
'Uploader.Attachment' => array(
'image' => array(
'uploadDir' => 'img/users/',
'overwrite' => true,
'transforms' => array(
'image' => array(
'nameCallback' => 'formatName',
'class' => 'crop',
'self' => true,
'width' => 180,
'height' => 180
)
)
)
),
'Uploader.FileValidation' => array(
'image' => array(
'extension' => array('jpg', 'png', 'jpeg'),
'required' => array(
'value' => false,
'allowEmpty' => true
)
)
)
);
/**
* Retorna o nome em formato slug
*/
public function formatName() {
return $this->slugify($this->data['User']['name']);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment