php - How to pass multiple parameter for laravel route in jquery

var url = "{{ route('order-detail',':slug') }}";
console.log(url);

I want to add one more parameter id after slug:

var url = "{{ route('order-detail',':slug',':id') }}";
console.log(url);

This is the error:

Missing required parameter for [Route: order-detail] [URI: orders/detail/{slug}/{id}] [Missing parameter: id]. (View: /var/www/html/projectname/Modules/Orders/Resources/views/new-orders.blade.php)

Answer

Solution:

First off, create two variables slug and id

var slug = ...;
var id = ...;
// you should know how to get this, you didn't show your full code
// so I can't know

Next, create your url variable like this:

var url = "{{ route('order-detail', ['slug' => ':slug', 'id' => ':id']) }}";
url = url.replace(':id', id);
url = url.replace(':slug', slug);

Now this should give you an appropriate route url

Answer

Solution:

Try

var url = "{{ route('order-detail', [':slug', ':id']) }}";

Source