Пример #1
0
 public function run()
 {
     $faker = Faker::create();
     $courseIds = Course::lists('id')->all();
     $studentIds = Student::lists('id')->all();
     //        dd($studentIds);
     foreach (range(1, count($courseIds)) as $index) {
         DB::table('course_student')->insert(['course_id' => $faker->randomElement($courseIds), 'student_id' => $faker->randomElement($studentIds)]);
     }
 }
 /**
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function viewResultForm()
 {
     if (Auth::user()->is('Admin')) {
         $students = Student::lists('registration_no', 'registration_no');
     } elseif (Auth::user()->is('Student')) {
         $students = Student::where('email', Auth::user()->email)->value('registration_no');
     }
     //        $pdf = PDF::loadView('layouts.viewResult', ['students' => $students]);
     //        return $pdf->download('result.pdf');
     return view('layouts.viewResult', ['students' => $students]);
 }