mirror of
https://github.com/robonen/education-project.git
synced 2026-03-20 02:44:31 +00:00
Получение предметов и учеников класса, классов учителя
This commit is contained in:
@@ -51,7 +51,7 @@ class SchoolClassController extends Controller
|
||||
}
|
||||
|
||||
//добавление, изменение классного руководителя
|
||||
public function addClassroomTeacher(SchoolClass $class, Request $request)
|
||||
public function addTeacher(SchoolClass $class, Request $request)
|
||||
{
|
||||
$teacher = Teacher::findOrfail((int)$request->input('teacher_id'));
|
||||
$class->classroom_teacher = $teacher->id;
|
||||
@@ -59,4 +59,26 @@ class SchoolClassController extends Controller
|
||||
return response()->json(SchoolClass::find($class->id), 200);
|
||||
}
|
||||
|
||||
//получение всех учеников в классе
|
||||
public function getStudents(SchoolClass $class)
|
||||
{
|
||||
$students = $class->students;
|
||||
$studentsOnlyFIO = [];
|
||||
foreach ($students as $student) {
|
||||
array_push($studentsOnlyFIO, $student->only('id', 'name', 'surname', 'patronymic'));
|
||||
}
|
||||
return response()->json($studentsOnlyFIO, 200);
|
||||
}
|
||||
|
||||
//получение всех предметов для класса
|
||||
public function getSubjects(SchoolClass $class)
|
||||
{
|
||||
$subjects = $class->subjects;
|
||||
$subjectExceptPivot = [];
|
||||
foreach ($subjects as $subject) {
|
||||
array_push($subjectExceptPivot, collect($subject)->except('pivot'));
|
||||
}
|
||||
return response()->json($subjectExceptPivot, 200);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user