Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- web route
- =====================================================
- Route::post('myStudents/attendance', 'Admin\InstructorController@submitAttendance')->name('myStudents.attendance');
- Admin.Instructor Controller
- =====================================================
- public function submitAttendance(Request $request) {
- // Loop through all the students for the course.
- // Here I have just looped through all students in your db
- foreach (Student::all() as $student) {
- if ($request->get('report_'.$student->id)) {
- dump($student->id .' -> '.$request->get('report_'.$student->id));
- }
- }
- }
- myStudent.blade.php
- =====================================================
- <form action="{{ route('admin.myStudents.attendance') }}" method="POST">
- {{ csrf_field() }}
- <div class="data-tables">
- <table id="dataTable" class="text-center">
- .......
- <tbody>
- @foreach ($students as $student )
- @if($student->student_status == null)
- <tr>
- .......
- <td>
- <input type="hidden" name="student_id" value="{{ $student->id }}">
- <input type="hidden" name="course_id"
- value="{{ $student->courses->first()->id }}">
- <input type="hidden" name="instructor_id" value="{{ $instructor->id }}">
- <div class="form-check form-check-inline">
- <input class="form-check-input"
- {{ old('report_'.$student->id) === 'present' ? 'checked' : ''}}
- type="radio" name="{{ 'report_'.$student->id }}"
- id="{{ 'present_'.$student->id }}" value="present">
- <label class="form-check-label" for="{{ 'present_'.$student->id }}">Present</label>
- <p id="demo"></p>
- </div>
- <div class="form-check form-check-inline">
- <input class="form-check-input"
- {{ !old('report_'.$student->id) || old('report_'.$student->id) !== 'present' ? 'checked' : ''}}
- type="radio" name="{{ 'report_'.$student->id }}"
- id="{{ 'absent_'.$student->id }}" value="absent">
- <label class="form-check-label" for="{{ 'absent_'.$student->id }}">Absent</label>
- </div>
- </td>
- </tr>
- @endif
- @endforeach
- </tbody>
- </table>
- </div>
- <div class="text-right mt-3">
- <button type="submit" class="btn btn-block btn-primary">Submit Attendance</button>
- </div>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement