Courses

Creating a Quiz System with Laravel 10 + Livewire 3: Step-by-Step

Now that we show results after quiz was taken, let's show results for a user from all their taken quizzes.

my results page

First, we'll add a new method to the ResultController.

app/Http/Controllers/ResultController.php:

class ResultController extends Controller
{
public function index(): View
{
$results = Test::with('quiz')->withCount('questions')->where('user_id', auth()->id())->paginate();
 
return view('front.results.index', $results);
}
// ...
}

Add the route.

routes/web.php:

// ...
Route::middleware('auth')->group(function () {
Route::get('results', [ResultController::class, 'index'])->name('results.index');
 
// ...
});
// ...

Of course, we need to add link to the navigation. But it needs to be wrapped in @auth directive...

This lesson is only for Premium Members.
Want to access all lessons of this course?

You also get:

  • 68 courses (1183 lessons, 43 h 18 min total)
  • Premium tutorials
  • Access to repositories
  • Private Discord