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_start" : "2017-04-01 12:00:00",
- "task_end" : "2017-04-01 02:00:00",
- "task_created_at" : "2017-04-01 02:17:00",
- "task_updated_at" : "2017-04-01 02:17:00",
- "employee_id" : [
- ObjectId("586ca8c71a72cb07a681566d"),
- ObjectId("586ca8d31a72cb07a6815671")
- ]
- },
- {
- "_id" : ObjectId("586cd3261a72cb07a6815c69"),
- "task_name" : "2nd Task",
- "task_description" : "test description",
- "task_status" : 1,
- "task_start" : "2017-04-01 12:00:00",
- "task_end" : "2017-04-01 02:00:00",
- "task_created_at" : "2017-04-01 02:17:00",
- "task_updated_at" : "2017-04-01 02:17:00",
- "employee_id" : ObjectId("586ca8c71a72cb07a681566d")
- }
- <?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->belongsTo('AppModelsEmployee');
- }
- }
- public function EmployeeData($data)
- {
- $employees = Employee::with('tasks')->where('_id', new MongoDBBSONObjectID('586ca8d31a72cb07a6815671'))->get();
- echo "<pre>";
- print_r($employees);exit;
- }
- IlluminateDatabaseEloquentCollection Object
- (
- [items:protected] => Array
- (
- [0] => AppModelsEmployee Object
- (
- [connection:protected] => mongodb
- [collection:protected] => lt_employees
- [primaryKey:protected] => _id
- [employee_id:AppModelsEmployee:private] =>
- [employee_name:AppModelsEmployee:private] =>
- [employee_description:AppModelsEmployee:private] =>
- [employee_email:AppModelsEmployee:private] =>
- [employee_created_at:AppModelsEmployee:private] =>
- [employee_updated_at:AppModelsEmployee:private] =>
- [parentRelation:protected] =>
- [table:protected] =>
- [keyType:protected] => int
- [perPage:protected] => 15
- [incrementing] => 1
- [timestamps] => 1
- [attributes:protected] => Array
- (
- [_id] => MongoDBBSONObjectID Object
- (
- [oid] => 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
- )
- [original:protected] => Array
- (
- [_id] => MongoDBBSONObjectID Object
- (
- [oid] => 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
- )
- [relations:protected] => Array
- (
- [tasks] => IlluminateDatabaseEloquentCollection Object
- (
- [items:protected] => Array
- (
- )
- )
- )
- [hidden:protected] => Array
- (
- )
- [visible:protected] => Array
- (
- )
- [appends:protected] => Array
- (
- )
- [fillable:protected] => Array
- (
- )
- [guarded:protected] => Array
- (
- [0] => *
- )
- [dates:protected] => Array
- (
- )
- [dateFormat:protected] =>
- [casts:protected] => Array
- (
- )
- [touches:protected] => Array
- (
- )
- [observables:protected] => Array
- (
- )
- [with:protected] => Array
- (
- )
- [exists] => 1
- [wasRecentlyCreated] =>
- )
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement