Advertisement
Guest User

influencer model

a guest
Sep 17th, 2014
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. <?php
  2. App::uses('AppModel', 'Model');
  3. /**
  4. * Influencer Model
  5. *
  6. * @property User $User
  7. * @property EventInvite $EventInvite
  8. * @property Club $Club
  9. */
  10. class Influencer extends AppModel {
  11.  
  12. /**
  13. * Display field
  14. *
  15. * @var string
  16. */
  17. public $displayField = 'id';
  18.  
  19.  
  20. //The Associations below have been created with all possible keys, those that are not needed can be removed
  21.  
  22. /**
  23. * belongsTo associations
  24. *
  25. * @var array
  26. */
  27. public $belongsTo = array(
  28. 'User' => array(
  29. 'className' => 'User',
  30. 'foreignKey' => 'user_id',
  31. 'conditions' => '',
  32. 'fields' => '',
  33. 'order' => ''
  34. )
  35. );
  36.  
  37. /**
  38. * hasMany associations
  39. *
  40. * @var array
  41. */
  42. public $hasMany = array(
  43. 'EventInvite' => array(
  44. 'className' => 'EventInvite',
  45. 'foreignKey' => 'influencer_id',
  46. 'dependent' => false,
  47. 'conditions' => '',
  48. 'fields' => '',
  49. 'order' => '',
  50. 'limit' => '',
  51. 'offset' => '',
  52. 'exclusive' => '',
  53. 'finderQuery' => '',
  54. 'counterQuery' => ''
  55. )
  56. );
  57.  
  58.  
  59. /**
  60. * hasAndBelongsToMany associations
  61. *
  62. * @var array
  63. */
  64. public $hasAndBelongsToMany = array(
  65. 'Club' => array(
  66. 'className' => 'Club',
  67. 'joinTable' => 'clubs_influencers',
  68. 'foreignKey' => 'influencer_id',
  69. 'associationForeignKey' => 'club_id',
  70. 'unique' => 'keepExisting',
  71. 'conditions' => '',
  72. 'fields' => '',
  73. 'order' => '',
  74. 'limit' => '',
  75. 'offset' => '',
  76. 'finderQuery' => '',
  77. )
  78. );
  79.  
  80. /**
  81. * Function for adding an influencer
  82. * @param [type] $data
  83. */
  84. public function addInfluencer($data){
  85.  
  86.  
  87. //influencers group is 9
  88. $data['User']['Group']['id'] = 9;
  89.  
  90. // Default language English
  91. $data['User']['language_id'] = 1;
  92.  
  93. //set the clubid to the club that you're currently logged in to or/and viewing
  94. $data['Club']['id']=$clubId;
  95.  
  96. $data = $this->ClubsInfluencer->saveAll($data);
  97.  
  98. }
  99.  
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement