/** * Handle the event. * * @param StudentChoseClassroom $event * @return void */ public function handle(StudentExitClassroom $event) { $classroom = $event->classroom; $student = $event->student; $user = $event->user; $notes = $event->notes; if (empty($user)) { $description = 'قام الطالب ' . $student->code . ' بالغاء اختيار الشعبة ' . $classroom->code; } else { $description = 'قام ' . $user->name . ' بحذف الطالب ' . $student->code . ' من الشعبة ' . $classroom->code; } $data = ['student_id' => $student->id, 'semester_id' => semester()->id, 'description' => $description, 'notes' => $notes, 'user_id' => !empty($user) ? $user->id : NULL]; $history = StudentClassroomHistory::create($data); }
public function index($student_id) { $histories = StudentClassroomHistory::inCurrentSemester()->with('creator')->where("student_id", $student_id)->get(); $student = Student::find($student_id); return view('students::classrooms.histories.index', compact('histories', 'student')); }