fix for not validating data after page refresh
This commit is contained in:
parent
8d488a87f8
commit
e46e8ce3d2
@ -141,6 +141,15 @@ class UserClassesController extends Controller {
|
||||
$student_name = $request->input('student_name');
|
||||
$student_surname = $request->input('student_surname');
|
||||
$seat_number = $request->input('seat_number');
|
||||
$classes = Classes::find($request->get('classes_id'));
|
||||
$attendances = Attendance::where('classes_id', $classes->id)->get();
|
||||
$student_ids = $attendances->pluck('student_id_number')->toArray();
|
||||
|
||||
if (in_array($student_id_number, $student_ids)) { // if student attendance record already exists
|
||||
$student_seat_number = Attendance::where('student_id_number', $student_id_number)->first()->seat_number;
|
||||
$warning = 'Ten numer indeksu został już wcześniej zapisany na te zajęcia.';
|
||||
return view('map.summary_map', ['student_name' => $student_name, 'student_surname' => $student_surname, 'seat_number' => $student_seat_number, 'student_id_number' => $student_id_number, 'classes_id' => $classes->id, 'mode' => $classes->mode, 'warning' => $warning]);
|
||||
} else {
|
||||
Attendance::create([
|
||||
'classes_id' => $classes_id,
|
||||
'student_id_number' => $student_id_number,
|
||||
@ -150,6 +159,7 @@ class UserClassesController extends Controller {
|
||||
]);
|
||||
return view('map.summary_map', ['student_name' => $student_name, 'student_surname' => $student_surname, 'seat_number' => $seat_number, 'student_id_number' => $student_id_number, 'classes_id' => $classes_id, 'mode' => null, 'warning' => null]);
|
||||
}
|
||||
}
|
||||
|
||||
public function preview_classes($classes_id, $orderBy = 'student_surname', $orderDirection = 'ASC') {
|
||||
if (!$classes_id == 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user