Log.php 750 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. App::uses('ToolsAppModel', 'Tools.Model');
  3. if (!defined('CLASS_USER')) {
  4. define('CLASS_USER', 'User');
  5. }
  6. /**
  7. * `logs` table populated by LogableBehavior
  8. */
  9. class Log extends ToolsAppModel {
  10. public $order = array('Log.created'=>'DESC');
  11. public $belongsTo = array(
  12. 'User' => array(
  13. 'className' => CLASS_USER,
  14. 'foreignKey' => 'user_id',
  15. 'conditions' => '',
  16. 'fields' => array('id', 'username'),
  17. 'order' => ''
  18. ),
  19. );
  20. /**
  21. * not really necessary probably
  22. */
  23. public function find($type = null, $query = array()) {
  24. if ($type === 'last') {
  25. $options = array_merge(array('order'=>array($this->alias.'.id'=>'DESC')), $query);
  26. return parent::find('first', $options);
  27. }
  28. return parent::find($type, $query);
  29. }
  30. }