-
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, <?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.
Answered by
divine
Dec 23, 2020
Replies: 1 comment 4 replies
-
Hello, Try changing Thanks! |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
divine
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello,
Try changing
"lesson_id": ObjectId("5fd84e467f180d5db02be90f")
to string type"lesson_id": "5fd84e467f180d5db02be90f"
Thanks!