Advertisement
Guest User

Untitled

a guest
Jan 7th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.86 KB | None | 0 0
  1. {
  2. "_id" : ObjectId("586ca8c71a72cb07a681566d"),
  3. "employee_name" : "John",
  4. "employee_description" : "test description",
  5. "employee_email" : "john@email.com",
  6. "updated_at" : "2017-01-04 11:45:20",
  7. "created_at" : "2017-01-04 11:45:20"
  8. },
  9. {
  10. "_id" : ObjectId("586ca8d31a72cb07a6815671"),
  11. "employee_name" : "Carlos",
  12. "employee_description" : "test description",
  13. "employee_email" : "carlos@email.com",
  14. "updated_at" : "2017-01-04 11:45:20",
  15. "created_at" : "2017-01-04 11:45:20"
  16. }
  17.  
  18. {
  19. "_id" : ObjectId("586ccbcf1a72cb07a6815b04"),
  20. "task_name" : "New Task",
  21. "task_description" : "test description",
  22. "task_status" : 1,
  23. "task_start" : "2017-04-01 12:00:00",
  24. "task_end" : "2017-04-01 02:00:00",
  25. "task_created_at" : "2017-04-01 02:17:00",
  26. "task_updated_at" : "2017-04-01 02:17:00",
  27. "employee_id" : [
  28. ObjectId("586ca8c71a72cb07a681566d"),
  29. ObjectId("586ca8d31a72cb07a6815671")
  30. ]
  31. },
  32. {
  33. "_id" : ObjectId("586cd3261a72cb07a6815c69"),
  34. "task_name" : "2nd Task",
  35. "task_description" : "test description",
  36. "task_status" : 1,
  37. "task_start" : "2017-04-01 12:00:00",
  38. "task_end" : "2017-04-01 02:00:00",
  39. "task_created_at" : "2017-04-01 02:17:00",
  40. "task_updated_at" : "2017-04-01 02:17:00",
  41. "employee_id" : ObjectId("586ca8c71a72cb07a681566d")
  42. }
  43.  
  44. <?php
  45. namespace AppModels;
  46.  
  47. use JenssegersMongodbEloquentModel as Eloquent;
  48.  
  49. class Employee extends Eloquent {
  50.  
  51. protected $collection = 'employee';
  52. protected $primaryKey = '_id';
  53.  
  54. public function tasks()
  55. {
  56. return $this->hasMany('AppModelsTask');
  57. }
  58. }
  59.  
  60. <?php
  61. namespace AppModels;
  62.  
  63. use JenssegersMongodbEloquentModel as Eloquent;
  64.  
  65. class Task extends Eloquent {
  66.  
  67. protected $collection = 'task';
  68. protected $primaryKey = '_id';
  69.  
  70. public function employees()
  71. {
  72. return $this->belongsTo('AppModelsEmployee');
  73. }
  74. }
  75.  
  76. public function EmployeeData($data)
  77. {
  78. $employees = Employee::with('tasks')->where('_id', new MongoDBBSONObjectID('586ca8d31a72cb07a6815671'))->get();
  79. echo "<pre>";
  80. print_r($employees);exit;
  81. }
  82.  
  83. IlluminateDatabaseEloquentCollection Object
  84. (
  85. [items:protected] => Array
  86. (
  87. [0] => AppModelsEmployee Object
  88. (
  89. [connection:protected] => mongodb
  90. [collection:protected] => lt_employees
  91. [primaryKey:protected] => _id
  92. [employee_id:AppModelsEmployee:private] =>
  93. [employee_name:AppModelsEmployee:private] =>
  94. [employee_description:AppModelsEmployee:private] =>
  95. [employee_email:AppModelsEmployee:private] =>
  96. [employee_created_at:AppModelsEmployee:private] =>
  97. [employee_updated_at:AppModelsEmployee:private] =>
  98. [parentRelation:protected] =>
  99. [table:protected] =>
  100. [keyType:protected] => int
  101. [perPage:protected] => 15
  102. [incrementing] => 1
  103. [timestamps] => 1
  104. [attributes:protected] => Array
  105. (
  106. [_id] => MongoDBBSONObjectID Object
  107. (
  108. [oid] => 586ca8d31a72cb07a6815671
  109. )
  110.  
  111. [employee_name] => Carlos
  112. [employee_description] => test description
  113. [employee_email] => carlos@email.com
  114. [updated_at] => 2017-01-04 11:45:20
  115. [created_at] => 2017-01-04 11:45:20
  116. )
  117.  
  118. [original:protected] => Array
  119. (
  120. [_id] => MongoDBBSONObjectID Object
  121. (
  122. [oid] => 586ca8d31a72cb07a6815671
  123. )
  124.  
  125. [employee_name] => Carlos
  126. [employee_description] => test description
  127. [employee_email] => carlos@email.com
  128. [updated_at] => 2017-01-04 11:45:20
  129. [created_at] => 2017-01-04 11:45:20
  130. )
  131.  
  132. [relations:protected] => Array
  133. (
  134. [tasks] => IlluminateDatabaseEloquentCollection Object
  135. (
  136. [items:protected] => Array
  137. (
  138. )
  139.  
  140. )
  141.  
  142. )
  143.  
  144. [hidden:protected] => Array
  145. (
  146. )
  147.  
  148. [visible:protected] => Array
  149. (
  150. )
  151.  
  152. [appends:protected] => Array
  153. (
  154. )
  155.  
  156. [fillable:protected] => Array
  157. (
  158. )
  159.  
  160. [guarded:protected] => Array
  161. (
  162. [0] => *
  163. )
  164.  
  165. [dates:protected] => Array
  166. (
  167. )
  168.  
  169. [dateFormat:protected] =>
  170. [casts:protected] => Array
  171. (
  172. )
  173.  
  174. [touches:protected] => Array
  175. (
  176. )
  177.  
  178. [observables:protected] => Array
  179. (
  180. )
  181.  
  182. [with:protected] => Array
  183. (
  184. )
  185.  
  186. [exists] => 1
  187. [wasRecentlyCreated] =>
  188. )
  189.  
  190. )
  191.  
  192. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement