where("student_id", $value); } } /** * 搜索器:学员课程课程 * @param $value * @param $data */ public function searchCourseIdAttr($query, $value, $data) { if ($value) { $query->where("course_id", $value); } } public function student(){ return $this->hasOne(Student::class, 'id', 'student_id'); } public function course(){ return $this->hasOne(Course::class, 'id', 'course_id'); } }