Log.php 719 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 = ['created' => 'DESC'];
  11. public $belongsTo = [
  12. 'User' => [
  13. 'className' => CLASS_USER,
  14. 'foreignKey' => 'user_id',
  15. 'conditions' => '',
  16. 'fields' => ['id', 'username'],
  17. 'order' => ''
  18. ],
  19. ];
  20. /**
  21. * Not really necessary probably
  22. */
  23. public function find($type = null, $query = []) {
  24. if ($type === 'last') {
  25. $options = array_merge(['order' => [$this->alias . '.id' => 'DESC']], $query);
  26. return parent::find('first', $options);
  27. }
  28. return parent::find($type, $query);
  29. }
  30. }