Friends.php 645 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace app\models;
  3. class Friends extends \lithium\data\Model {
  4. public $validates = array();
  5. public $belongsTo = array('User' => array('keys' => array('FromUserId' => 'id')));
  6. /**
  7. * Returns the opposite value of whatever is passed in (like an enum)
  8. * @param Mixed $input
  9. * @return String or Int;
  10. */
  11. public static function status($input) {
  12. if (is_int($input)) {
  13. switch($input) {
  14. case "rejected": return 0;
  15. case "accepted": return 1;
  16. case "open": return 2;
  17. }
  18. }
  19. else {
  20. switch($input) {
  21. case 0: return "rejected";
  22. case 1: return "accepted";
  23. case 2: return "open";
  24. }
  25. }
  26. }
  27. }
  28. ?>