Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.00 KB | None | 0 0
  1. web route
  2. =====================================================
  3.     Route::post('myStudents/attendance', 'Admin\InstructorController@submitAttendance')->name('myStudents.attendance');
  4.  
  5.  
  6. Admin.Instructor Controller
  7. =====================================================
  8.  
  9.     public function submitAttendance(Request $request) {
  10.  
  11.         // Loop through all the students for the course.
  12.         // Here I have just looped through all students in your db
  13.         foreach (Student::all() as $student) {
  14.             if ($request->get('report_'.$student->id)) {
  15.                 dump($student->id .' -> '.$request->get('report_'.$student->id));
  16.             }
  17.         }
  18.  
  19.     }
  20.  
  21. myStudent.blade.php
  22. =====================================================
  23. <form action="{{ route('admin.myStudents.attendance') }}" method="POST">
  24.     {{ csrf_field() }}
  25.  
  26.     <div class="data-tables">
  27.         <table id="dataTable" class="text-center">
  28.             .......
  29.             <tbody>
  30.  
  31.             @foreach ($students as $student )
  32.                 @if($student->student_status == null)
  33.                     <tr>
  34.                         .......
  35.  
  36.                         <td>
  37.                             <input type="hidden" name="student_id" value="{{ $student->id }}">
  38.                             <input type="hidden" name="course_id"
  39.                                    value="{{ $student->courses->first()->id }}">
  40.                             <input type="hidden" name="instructor_id" value="{{ $instructor->id }}">
  41.  
  42.  
  43.                             <div class="form-check form-check-inline">
  44.                                 <input class="form-check-input"
  45.                                        {{ old('report_'.$student->id) === 'present' ? 'checked' : ''}}
  46.                                        type="radio" name="{{ 'report_'.$student->id }}"
  47.                                        id="{{ 'present_'.$student->id }}" value="present">
  48.                                 <label class="form-check-label" for="{{ 'present_'.$student->id }}">Present</label>
  49.                                 <p id="demo"></p>
  50.                             </div>
  51.                             <div class="form-check form-check-inline">
  52.                                 <input class="form-check-input"
  53.                                        {{ !old('report_'.$student->id) || old('report_'.$student->id) !== 'present' ? 'checked' : ''}}
  54.                                        type="radio" name="{{ 'report_'.$student->id }}"
  55.                                        id="{{ 'absent_'.$student->id }}" value="absent">
  56.                                 <label class="form-check-label" for="{{ 'absent_'.$student->id }}">Absent</label>
  57.                             </div>
  58.                         </td>
  59.  
  60.                     </tr>
  61.                 @endif
  62.             @endforeach
  63.  
  64.             </tbody>
  65.         </table>
  66.     </div>
  67.  
  68.     <div class="text-right mt-3">
  69.         <button type="submit" class="btn btn-block btn-primary">Submit Attendance</button>
  70.     </div>
  71. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement