我无法在Laravel中获得正确的查询

时间:2017-12-15 08:15:38

标签: php laravel orm

我收到了一份声明,要求在Laravel获得一张唱片。但是,它有例外

Column not found: 1054 Unknown column 'isok_toteacher' in 'where clause'

$lessonDetail = Lesson::join('lesson','lesson_en.id_lesson','=','lesson.id')
                ->with('theme_id.theme_name.lesson_name.next_lesson')
                ->with(array('notes' => function($query){
                    $query->where('isok_toteacher','1');
                }))->remember(\Config::get('cache.redis_long'))->find($lessonId);

我打印出查询,它变为

select * from `teacher_notes` where `teacher_notes`.`id_teacher` = 13401 and `teacher_notes`.`id_lesson` in (27) and `isok_toteacher` = 1

我不太清楚为什么with(array('notes' => function($query)没有指向notes表而是指向teacher_notes并最终使列不可用。

0 个答案:

没有答案