logo-icon AndroidWale
  • Technology
  • Science
© 2025 AndroidWale.com
logo
  • Categories
    • Technology
    • Science
  • Login

How many types of route?

Author: Kundan kumar | Date: 04-06-2025

✅ 1. Basic Route This is the simplest form of routing using a closure.

This is the simplest form of routing using a closure.

Route::get('/hello', function () {
    return 'Hello, World!';
});

✅ 1. Basic Route This is the simplest form of routing using a closure.

This is the simplest form of routing using a closure.

Route::get('/hello', function () {
    return 'Hello, World!';
});

View route

Route::view('/about', 'about');

//You can also pass data
Route::view('/greet', 'greeting', ['name' => 'John']);

✅ 1. Basic Route This is the simplest form of routing using a closure.

This is the simplest form of routing using a closure.

Route::get('/hello', function () {
    return 'Hello, World!';
});

✅ 1. Basic Route This is the simplest form of routing using a closure.

This is the simplest form of routing using a closure.

Route::get('/hello', function () {
    return 'Hello, World!';
});

View route

Route::view('/about', 'about');

//You can also pass data
Route::view('/greet', 'greeting', ['name' => 'John']);

Redirect route

Route::redirect('/home', '/dashboard');

//You can also pass specific status code
Route::redirect('/old', '/new', 301);

Controller routes

Route::get('/user/{id}', [UserController::class, 'show']);

Route with parameter

Route::get('/post/{id}', function ($id) {
    return "Post ID: " . $id;
});

Named route

Group routes with shared attributes like middleware, prefix, or namespace.

Route::get('/profile', [UserController::class, 'profile'])->name('profile');

Route group

✅ 1. Basic Route This is the simplest form of routing using a closure.

This is the simplest form of routing using a closure.

Route::get('/hello', function () {
    return 'Hello, World!';
});

✅ 1. Basic Route This is the simplest form of routing using a closure.

This is the simplest form of routing using a closure.

Route::get('/hello', function () {
    return 'Hello, World!';
});

View route

Route::view('/about', 'about');

//You can also pass data
Route::view('/greet', 'greeting', ['name' => 'John']);

Redirect route

Route::redirect('/home', '/dashboard');

//You can also pass specific status code
Route::redirect('/old', '/new', 301);

Controller routes

Route::get('/user/{id}', [UserController::class, 'show']);

Route with parameter

Route::get('/post/{id}', function ($id) {
    return "Post ID: " . $id;
});

Named route

Group routes with shared attributes like middleware, prefix, or namespace.

Route::get('/profile', [UserController::class, 'profile'])->name('profile');

Route group

Route::prefix('admin')->group(function () {
    Route::get('/dashboard', function () {
        return 'Admin Dashboard';
    });
});

Resource route

Generates routes like:

GET /posts

POST /posts

GET /posts/{id}

PUT /posts/{id}

DELETE /posts/{id}

Route::resource('posts', PostController::class);

✅ 9. API Resource Route

Same as resource but optimized for APIs (no create and edit).

Route::apiResource('users', UserController::class);

Fallback routes

Handles 404s when no other route matches.

Route::fallback(function () {
    return response()->json(['message' => 'Page Not Found.'], 404);
});

Route with Middleware

Route::get('/dashboard', function () {
    return 'Dashboard';
})->middleware('auth');

Comments

Comments:

No comments yet. Be the first to comment!

Related Posts

How to Add Dynamic drop-down

How to add ajax in our project?

How to send ajax request in laravel?

Categories

PHP (6)
JavaScript (1)
Boostrap (0)
Laravel (0)
Angular (0)

Popular Posts

  • How to send ajax request in laravel?
  • How to Add Dynamic drop-down
  • How to add ajax in our project?

Recent Posts

  • How many types of route?
  • this is JavaScript testing dummy content
  • Method: Real-Time Translation Using Google Transla...

Tags

php new this is testing android android54ff testing new android gg other new
Social Media
Social image 1
Social image 2
Social image 3
Social image 4
Social image 5
Social image 6

© 2025 AndroidWale. All Rights Reserved.

Follow us on Linkedin, Twitter, Instagram, and Facebook