Skip to main content

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...

The Full Lesson is Only for Premium Members

Want to access all of our courses? (30 h 09 min)

You also get:

55 courses
Premium tutorials
Access to repositories
Private Discord
Get Premium for $129/year or $29/month

Already a member? Login here

Comments & Discussion

No comments yet…

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.