public function index() { if (Auth::user()->role == 'student') { $quizzes = Quiz::all(); foreach ($quizzes as $quiz) { $quiz['participated'] = Auth::user()->student()->first()->quizzes()->get()->find($quiz->id) ? true : false; } return $quizzes->toJson(); } return Quiz::all()->toJson(); }
/** * Display a listing of the resource. * * @return Response */ public function index() { $quizzes = Quiz::all(); return view('site.quizzes.index')->with('quizzes', $quizzes); }