jeudi 30 avril 2020

Unable to make subquery in laravel 5.1 eloquent

I am trying to get some data using laravel eloquent with subquery, but couldn't make it work. I haven't done this before, so kinda dumb on this. Here is my query:

$assignedTeacherSubjectsObj = AssignedSubjectToTeacher::with(['class_info', 'subject', 'section', 'group', 'user' => function($query) {
                $query->select('user_id', 'full_name', 'phone_no');
            }])
            ->addSelect(["date_wise_assigned_homework" => Homework::whereColumn('tbl_assigned_subjects_to_teachers.institute_branch_version_id', 'tbl_homeworks.institute_branch_version_id')
                ->whereColumn('tbl_assigned_subjects_to_teachers.class_id', 'tbl_homeworks.class_id')
                ->whereColumn('tbl_assigned_subjects_to_teachers.group_id', 'tbl_homeworks.group_id')
                ->whereColumn('tbl_assigned_subjects_to_teachers.section_id', 'tbl_homeworks.section_id')
                ->whereColumn('tbl_assigned_subjects_to_teachers.subject_id', 'tbl_homeworks.subject_id')
                ->whereDate('homework_submissionDate', '>=', $request->HomeworkDateFrom)
                ->whereDate('homework_submissionDate', '<=', $request->HomeworkDateTo)
                ->get();
            ])
            ->where('is_active', 1)
            ->whereIn('institute_branch_version_id', $branchShiftVersionIds)
            ->orderBy('user_id')
            ->orderBy('class_id')
            ->get();

I am getting this error:

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tbl_assigned_subjects_to_teachers.institute_branch_version_id' in 'where clause' (SQL: select * from `tbl_homeworks` where `tbl_assigned_subjects_to_teachers`.`institute_branch_version_id` = tbl_homeworks.institute_branch_version_id and `tbl_assigned_subjects_to_teachers`.`class_id` = tbl_homeworks.class_id and `tbl_assigned_subjects_to_teachers`.`group_id` = tbl_homeworks.group_id and `tbl_assigned_subjects_to_teachers`.`section_id` = tbl_homeworks.section_id and `tbl_assigned_subjects_to_teachers`.`subject_id` = tbl_homeworks.subject_id and date(`homework_submissionDate`) >= 2020-03-24 and date(`homework_submissionDate`) <= 2020-03-30)

Can anyone help me out with this!



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2YjCgNb
via IFTTT

Aucun commentaire:

Enregistrer un commentaire