-
Notifications
You must be signed in to change notification settings - Fork 1.5k
-
So I have this table
// table name: coz_lessons_changes { "_id": ObjectId("5fdd41cfc8c832ba57cdb3a6"), "lesson_id": ObjectId("5fd84e467f180d5db02be90f"), "to_status": "booking" }
and I have another table
// table name: coz_lessons { "_id": ObjectId("5fd84e467f180d5db02be90f"), "student_uid": NumberInt("3151989"), "activated": true, }
coz_lessons is the main table, and the coz_lessons_changes has a field called lesson_id which is the foreign key from coz_lessons.
how to set the function here so that it will know what to get,
bellow is my initial code but cant make it work.
<?php namespace App\Models\CozLesson; use Jenssegers\Mongodb\Eloquent\Model as Eloquent; class CozLesson extends Eloquent { protected $connection = 'utalk_server'; //need to set the connection protected $collection = 'coz_lessons'; //pangalan ng table public function coz_lesson_changes() { return $this->hasMany(CozLessonChanges::class,'lesson_id','_id'); } public function getLessonChanges($request) { $lesson = CozLesson::find($request->input('id')); $data = $lesson->coz_lesson_changes()->get(); return $data; } }
Beta Was this translation helpful? Give feedback.
All reactions
Hello,
Try changing "lesson_id": ObjectId("5fd84e467f180d5db02be90f")
to string type "lesson_id": "5fd84e467f180d5db02be90f"
Thanks!
Replies: 1 comment 4 replies
-
Hello,
Try changing "lesson_id": ObjectId("5fd84e467f180d5db02be90f")
to string type "lesson_id": "5fd84e467f180d5db02be90f"
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
oh yeah, the problem, other team generated it but our team has to get it even if it's as object id. Is there any alternative besides converting to a string? Thanks 😊
Beta Was this translation helpful? Give feedback.
All reactions
-
oh yeah, the problem, other team generated it but our team has to get it even if it's as object id. Is there any alternative besides converting to a string? Thanks 😊
It's actually a bug, however, fixing it will be a breaking change for existing applications so it's basically being delayed.
Keep in mind that this library doesn't correctly use ObjectIds. I don't know what the solution might be...
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
oh thanks..
Beta Was this translation helpful? Give feedback.
All reactions
-
Beta Was this translation helpful? Give feedback.
All reactions
-
❤️ 1