From d8591e3e9f0afebefc959a9fc4ae430d5343cf18 Mon Sep 17 00:00:00 2001 From: madproject105 <156641148+madproject105@users.noreply.github.com> Date: Fri, 29 Nov 2024 00:29:37 +0500 Subject: [PATCH] Routing Test cleared. --- .env.example | 51 --------------------------------- .github/workflows/laravel.yml | 2 +- routes/api.php | 7 +++-- routes/web.php | 54 ++++++++++++++++------------------- 4 files changed, 31 insertions(+), 83 deletions(-) delete mode 100644 .env.example diff --git a/.env.example b/.env.example deleted file mode 100644 index d9e6dcb9a..000000000 --- a/.env.example +++ /dev/null @@ -1,51 +0,0 @@ -APP_NAME=Laravel -APP_ENV=local -APP_KEY= -APP_DEBUG=true -APP_URL=http://localhost - -LOG_CHANNEL=stack -LOG_LEVEL=debug - -DB_CONNECTION=mysql -DB_HOST=127.0.0.1 -DB_PORT=3306 -DB_DATABASE=project2 -DB_USERNAME=root -DB_PASSWORD= - -BROADCAST_DRIVER=log -CACHE_DRIVER=file -FILESYSTEM_DRIVER=local -QUEUE_CONNECTION=sync -SESSION_DRIVER=file -SESSION_LIFETIME=120 - -MEMCACHED_HOST=127.0.0.1 - -REDIS_HOST=127.0.0.1 -REDIS_PASSWORD=null -REDIS_PORT=6379 - -MAIL_MAILER=smtp -MAIL_HOST=mailhog -MAIL_PORT=1025 -MAIL_USERNAME=null -MAIL_PASSWORD=null -MAIL_ENCRYPTION=null -MAIL_FROM_ADDRESS=null -MAIL_FROM_NAME="${APP_NAME}" - -AWS_ACCESS_KEY_ID= -AWS_SECRET_ACCESS_KEY= -AWS_DEFAULT_REGION=us-east-1 -AWS_BUCKET= -AWS_USE_PATH_STYLE_ENDPOINT=false - -PUSHER_APP_ID= -PUSHER_APP_KEY= -PUSHER_APP_SECRET= -PUSHER_APP_CLUSTER=mt1 - -MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}" -MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}" diff --git a/.github/workflows/laravel.yml b/.github/workflows/laravel.yml index e5dd1db06..9efe30a37 100644 --- a/.github/workflows/laravel.yml +++ b/.github/workflows/laravel.yml @@ -16,7 +16,7 @@ jobs: php-version: "8.1" - uses: actions/checkout@v2 - name: Copy .env - run: php -r "file_exists('.env') || copy('.env.example', '.env');" + run: php -r "file_exists('.env') || copy('.env', '.env');" - name: Install Dependencies run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - name: Generate key diff --git a/routes/api.php b/routes/api.php index 39ecc07c6..6175f05e5 100644 --- a/routes/api.php +++ b/routes/api.php @@ -21,7 +21,10 @@ Route::group(['middleware' => 'auth:sanctum'], function() { // Task 12: Manage tasks with endpoint /api/v1/tasks/*****. // Keep in mind that prefix should be /api/v1. - // Add ONE line to assign 5 resource routes to TaskController - // Put one code line here below + Route::prefix('/v1')->group(function(){ + // Add ONE line to assign 5 resource routes to TaskController + // Put one code line here below + Route::resource('/tasks', \App\Http\Controllers\Api\V1\TaskController::class); + }); }); diff --git a/routes/web.php b/routes/web.php index 15508ce8d..9938bbbc7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -15,69 +15,65 @@ // Task 1: point the main "/" URL to the HomeController method "index" // Put one code line here below - +Route::get('/', [\App\Http\Controllers\HomeController::class, 'index']); // 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 // Put one code line here below - +Route::get('/user/{name}', [\App\Http\Controllers\UserController::class, 'show']); // Task 3: point the GET URL "/about" to the view // resources/views/pages/about.blade.php - without any controller // Also, assign the route name "about" // Put one code line here below - +Route::get('/about', function(){ + return view('pages.about'); +})->name('about'); // Task 4: redirect the GET URL "log-in" to a URL "login" // Put one code line here below - +Route::redirect('/log-in','/login'); // Task 5: group the following route sentences below in Route::group() // Assign middleware "auth" // Put one Route Group code line here below - +Route::middleware('auth')->group(function(){ // Tasks inside that Authenticated group: - // Task 6: /app group within a group // Add another group for routes with prefix "app" // Put one Route Group code line here below - + Route::prefix('/app')->group(function(){ // Tasks inside that /app group: - - // Task 7: point URL /app/dashboard to a "Single Action" DashboardController // Assign the route name "dashboard" // Put one Route Group code line here below - - + Route::get('/dashboard', \App\Http\Controllers\DashboardController::class) + ->name('dashboard'); // Task 8: Manage tasks with URL /app/tasks/***. // Add ONE line to assign 7 resource routes to TaskController // Put one code line here below - + Route::resource('tasks', \App\Http\Controllers\TaskController::class); + }); // End of the /app Route Group - - // Task 9: /admin group within a group // Add a group for routes with URL prefix "admin" // Assign middleware called "is_admin" to them // Put one Route Group code line here below - - - // Tasks inside that /admin group: - - - // Task 10: point URL /admin/dashboard to a "Single Action" Admin/DashboardController - // Put one code line here below - - - // Task 11: point URL /admin/stats to a "Single Action" Admin/StatsController - // Put one code line here below - - - // End of the /admin Route Group - + Route::prefix('/admin')->group(function(){ + Route::middleware('is_admin')->group(function(){ + // Tasks inside that /admin group: + // Task 10: point URL /admin/dashboard to a "Single Action" Admin/DashboardController + // Put one code line here below + Route::get('/dashboard', \App\Http\Controllers\Admin\DashboardController::class); + // Task 11: point URL /admin/stats to a "Single Action" Admin/StatsController + // Put one code line here below + Route::get('/stats', \App\Http\Controllers\Admin\StatsController::class); + // End of the /admin Route Group + }); + }); // End of the main Authenticated Route Group +}); // One more task is in routes/api.php require __DIR__.'/auth.php';