complete task 6

This commit is contained in:
Thuan Bui
2025-04-02 09:13:39 +09:00
parent e6b2cd970d
commit 8cc4f76eda
+26 -4
View File
@@ -1,10 +1,10 @@
<?php <?php
use App\Http\Controllers\HomeController; use App\Http\Controllers\HomeController;
use App\Http\Controllers\TaskController;
use App\Http\Controllers\UserController; use App\Http\Controllers\UserController;
use Illuminate\Support\Facades\Route; use Illuminate\Support\Facades\Route;
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
| Web Routes | Web Routes
@@ -21,11 +21,10 @@ use Illuminate\Support\Facades\Route;
Route::get('/', [HomeController::class, 'index']); Route::get('/', [HomeController::class, 'index']);
// Task 2: point the GET URL "/user/[name]" to the UserController method "show" // Task 2: point the GET URL "/user/[name]" to the UserController method "show"
// It doesn't use Route Model Binding, it expects $name as a parameter // It doesn't use Route Model Binding, it expects $name as a parameter
// Put one code line here below // Put one code line here below
Route::get("/user/{name}", [UserController::class, 'show']); Route::get('/user/{name}', [UserController::class, 'show']);
// Task 3: point the GET URL "/about" to the view // Task 3: point the GET URL "/about" to the view
// resources/views/pages/about.blade.php - without any controller // resources/views/pages/about.blade.php - without any controller
@@ -33,7 +32,6 @@ Route::get("/user/{name}", [UserController::class, 'show']);
// Put one code line here below // Put one code line here below
Route::view('/about', view: 'pages.about')->name('about'); Route::view('/about', view: 'pages.about')->name('about');
// Task 4: redirect the GET URL "log-in" to a URL "login" // Task 4: redirect the GET URL "log-in" to a URL "login"
// Put one code line here below // Put one code line here below
Route::get('/log-in', function () { return redirect('/login'); }); Route::get('/log-in', function () { return redirect('/login'); });
@@ -44,10 +42,34 @@ Route::get('/log-in', function () { return redirect('/login'); });
// Tasks inside that Authenticated group: // Tasks inside that Authenticated group:
Route::middleware('auth')->group(function () {
Route::view('/app/dashboard', view: 'dashboard')->name('dashboard');
Route::get('/app/tasks', [TaskController::class, 'index'])->name('tasks.index');;
});
// Task 6: /app group within a group // Task 6: /app group within a group
// Add another group for routes with prefix "app" // Add another group for routes with prefix "app"
// Put one Route Group code line here below // Put one Route Group code line here below
Route::prefix('app')
->name('tasks.')
->middleware('auth')
->group(function () {
Route::get('/tasks', [TaskController::class, 'index'])->name('index');
Route::post('/tasks', [TaskController::class, 'store'])->name('store');
Route::get('/tasks/create', [TaskController::class, 'create'])->name('create');
Route::get('/tasks/{task}', [TaskController::class, 'show'])->name('show');
Route::get('/tasks/{task}/edit', [TaskController::class, 'edit'])->name('edit');
Route::put('/tasks/{task}', [TaskController::class, 'update'])->name('update');
Route::delete('/tasks/{task}', [TaskController::class, 'destroy'])->name('destroy');
});
// Tasks inside that /app group: // Tasks inside that /app group:
// Task 7: point URL /app/dashboard to a "Single Action" DashboardController // Task 7: point URL /app/dashboard to a "Single Action" DashboardController