Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "_id" : ObjectId("586ca8c71a72cb07a681566d"),
- "employee_name" : "John",
- "employee_description" : "test description",
- "employee_email" : "john@email.com",
- "updated_at" : "2017-01-04 11:45:20",
- "created_at" : "2017-01-04 11:45:20"
- },
- {
- "_id" : ObjectId("586ca8d31a72cb07a6815671"),
- "employee_name" : "Carlos",
- "employee_description" : "test description",
- "employee_email" : "carlos@email.com",
- "updated_at" : "2017-01-04 11:45:20",
- "created_at" : "2017-01-04 11:45:20"
- }
- {
- "_id" : ObjectId("586ccbcf1a72cb07a6815b04"),
- "task_name" : "New Task",
- "task_description" : "test description",
- "task_status" : 1,
- "task_created_at" : "2017-04-01 02:17:00",
- "task_updated_at" : "2017-04-01 02:17:00"
- },
- {
- "_id" : ObjectId("586cd3261a72cb07a6815c69"),
- "task_name" : "2nd Task",
- "task_description" : "test description",
- "task_status" : 1,
- "task_created_at" : "2017-04-01 02:17:00",
- "task_updated_at" : "2017-04-01 02:17:00"
- }
- {
- "_id" : ObjectId("586cd0cb1a72cb07a6815bf3"),
- "employee_task_employee_id" : "586ca8c71a72cb07a681566d",
- "employee_task_task_id" : "586ccbcf1a72cb07a6815b04",
- "status" : 1
- },
- {
- "_id" : ObjectId("586cd7851a72cb07a6815d7d"),
- "employee_task_employee_id" : "586ca8c71a72cb07a681566d",
- "employee_task_task_id" : "586cd3261a72cb07a6815c69",
- "status" : 1
- }
- <?php
- namespace AppModels;
- use JenssegersMongodbEloquentModel as Eloquent;
- class Employee extends Eloquent {
- protected $collection = 'employee';
- protected $primaryKey = '_id';
- public function tasks()
- {
- return $this->hasMany('AppModelsTask');
- }
- }
- <?php
- namespace AppModels;
- use JenssegersMongodbEloquentModel as Eloquent;
- class Task extends Eloquent {
- protected $collection = 'task';
- protected $primaryKey = '_id';
- public function employees()
- {
- return $this->belongsToMany('AppModelsEmployee');
- }
- }
- public function EmployeeData($data)
- {
- $employee= Employee::find('586ca8c71a72cb07a681566d')->tasks;
- echo "<pre>";
- print_r($employee);
- }
- IlluminateDatabaseEloquentCollection Object
- (
- [items:protected] => Array
- (
- )
- )
- <?php namespace AppModels;
- use JenssegersMongodbEloquentModel as Eloquent;
- class Employee extends Eloquent {
- protected $collection = 'employee';
- protected $primaryKey = '_id';
- public function tasks()
- {
- return $this->belongsToMany('AppModelsTask');
- }
- }
- <?php namespace AppModels;
- use JenssegersMongodbEloquentModel as Eloquent;
- class Task extends Eloquent {
- protected $collection = 'task';
- protected $primaryKey = '_id';
- public function employees()
- {
- return $this->belongsToMany('AppModelsEmployee');
- }
- }
- $employee= Employee::with('tasks')->find('586ca8c71a72cb07a681566d')->tasks;
- $employee->tasks()->save(new Task());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement