In this lesson, we will add a list of taken tests with their results that will only gonna be available for admin users.
For that, let's create a controller.
php artisan make:controller Admin/TestController
Add the route.
routes/web.php
// ...Route::middleware('auth')->group(function () { // ... Route::middleware('isAdmin')->group(function () { Route::get('questions', QuestionList::class)->name('questions'); Route::get('questions/create', QuestionForm::class)->name('questions.create'); Route::get('questions/{question}', QuestionForm::class)->name('questions.edit'); Route::get('quizzes', QuizList::class)->name('quizzes'); Route::get('quizzes/create', QuizForm::class)->name('quiz.create'); Route::get('quizzes/{quiz}', QuizForm::class)->name('quiz.edit'); Route::get('tests', TestController::class)->name('tests'); });});// ...
And the link in the navigation.
resources/views/layouts/navigation.blade.php:
// ...<x-slot name="content"> <x-dropdown-link :href="route('questions')"> Questions </x-dropdown-link> <x-dropdown-link :href="route('quizzes')"> Quizzes </x-dropdown-link> <x-dropdown-link :href="route('tests')"> Tests </x-dropdown-link> </x-slot>// ...
Now let's get all tests in the controller...