PageRenderTime 50ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/Contacts/Model/Contact.php

https://github.com/kareypowell/croogo
PHP | 100 lines | 54 code | 7 blank | 39 comment | 0 complexity | 235527b830be0e94f96f708bd3a004e6 MD5 | raw file
  1. <?php
  2. App::uses('ContactsAppModel', 'Contacts.Model');
  3. /**
  4. * Contact
  5. *
  6. * @category Model
  7. * @package Croogo.Contacts.Model
  8. * @version 1.0
  9. * @author Fahad Ibnay Heylaal <contact@fahad19.com>
  10. * @license http://www.opensource.org/licenses/mit-license.php The MIT License
  11. * @link http://www.croogo.org
  12. */
  13. class Contact extends ContactsAppModel {
  14. /**
  15. * Model name
  16. *
  17. * @var string
  18. * @access public
  19. */
  20. public $name = 'Contact';
  21. /**
  22. * Behaviors used by the Model
  23. *
  24. * @var array
  25. * @access public
  26. */
  27. public $actsAs = array(
  28. 'Croogo.Cached' => array(
  29. 'groups' => array(
  30. 'contacts',
  31. ),
  32. ),
  33. 'Croogo.Trackable',
  34. );
  35. /**
  36. * Validation
  37. *
  38. * @var array
  39. * @access public
  40. */
  41. public $validate = array(
  42. 'title' => array(
  43. 'rule' => 'notEmpty',
  44. 'message' => 'This field cannot be left blank.',
  45. ),
  46. 'alias' => array(
  47. 'isUnique' => array(
  48. 'rule' => 'isUnique',
  49. 'message' => 'This alias has already been taken.',
  50. ),
  51. 'minLength' => array(
  52. 'rule' => array('minLength', 1),
  53. 'message' => 'Alias cannot be empty.',
  54. ),
  55. ),
  56. 'email' => array(
  57. 'rule' => 'email',
  58. 'message' => 'Please provide a valid email address.',
  59. ),
  60. );
  61. /**
  62. * Model associations: hasMany
  63. *
  64. * @var array
  65. * @access public
  66. */
  67. public $hasMany = array(
  68. 'Message' => array(
  69. 'className' => 'Contacts.Message',
  70. 'foreignKey' => 'contact_id',
  71. 'dependent' => false,
  72. 'conditions' => '',
  73. 'fields' => '',
  74. 'order' => '',
  75. 'limit' => '3',
  76. 'offset' => '',
  77. 'exclusive' => '',
  78. 'finderQuery' => '',
  79. 'counterQuery' => '',
  80. ),
  81. );
  82. /**
  83. * Display fields for this model
  84. *
  85. * @var array
  86. */
  87. protected $_displayFields = array(
  88. 'id',
  89. 'title',
  90. 'alias',
  91. 'email',
  92. );
  93. }