首页 > 解决方案 > 如何在 Laravel sql 数据库关系中使用 where 子句

问题描述

我想使用来自学生功能的 national where equals national_id 搜索最后的道歉,我该怎么做?

我试过了:

return [
    'Students' => function ($students){
        $students->select('id', 'username','national_id', 'is_foreigner', 'college_id')
            ->with([
                'Apologies' => function ($apologies) use ($students) {

                    $apologies->select('student_id', 'reasons');
                    ->where('national', 'students.national_id');
                }
            ]);
    }
]

标签: phplaravel-5.2

解决方案


推荐阅读