How to pass multiple parameters in Laravel routes

How to pass multiple parameters in Laravel routes

Laravel is a powerful PHP framework used for developing web applications. Routing is an important aspect of any web application as it defines the way the application responds to a client request. Laravel makes it easy to define and handle routes with its simple and intuitive routing system. One common requirement when working with routes is the ability to pass multiple parameters to a single route. In this article, we'll explore how to pass multiple parameters in Laravel routes.


use Illuminate\Support\Facades\Route; 
use App\Http\Controllers\CustomerController;
Route::get('users/{user_id}/posts/{post_id}',[CustomerController::class, 'show'])->name("");



namespace App\Http\Controllers;  
use Illuminate\Http\Request;
class CustomerController extends Controller
     * Display a listing of the resource.
     * @return \Illuminate\Http\Response
    public function show(Request $request, $user_id, $post_id)
        dd($user_id, $post_id);



<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>how to pass multiple parameters in Laravel routes</title>
    <a href="{{ route('', ['user_id' => 1, 'post_id' => 10]) }}">Click Me</a>

I hope it is helpful to you. Thank you for reading this post.


No Comment posted Yet!

Leave a Reply

OK! You can skip this field.