mirror of
https://github.com/robonen/education-project.git
synced 2026-03-20 02:44:31 +00:00
Получение предметов и учеников класса, классов учителя
This commit is contained in:
@@ -17,12 +17,13 @@ class SchoolClass extends Model
|
||||
|
||||
public function students()
|
||||
{
|
||||
return $this->hasMany(Student::class);
|
||||
return $this->hasMany(Student::class, 'class_id');
|
||||
}
|
||||
|
||||
public function subjects()
|
||||
{
|
||||
return $this->belongsToMany(Subject::class, 'academic_plans')->withPivot('hours_per_week', 'hours_per_year');
|
||||
return $this->belongsToMany(Subject::class, 'academic_plans', 'class_id')
|
||||
->withPivot('hours_per_week', 'hours_per_year');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ class Subject extends Model
|
||||
|
||||
public function schoolClasses()
|
||||
{
|
||||
return $this->belongsToMany(SchoolClass::class, 'academic_plans')->withPivot('hours_per_week', 'hours_per_year');
|
||||
return $this->belongsToMany(SchoolClass::class, 'academic_plans', 'class_id')
|
||||
->withPivot('hours_per_week', 'hours_per_year');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,4 +19,9 @@ class Teacher extends Model
|
||||
return $this->hasOne(SchoolClass::class, 'classroom_teacher');
|
||||
}
|
||||
|
||||
public function timetables()
|
||||
{
|
||||
return $this->hasMany(Timetable::class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user