Jija
Jija

Reputation: 277

Getting wrong route variable value in laravel subdomain route

I am using this laravel route

Route::group(['domain' => '{subdomain}.abc.com'], function()
{
    Route::get('get_user/{user_id}','MyController@myMethod');
}

Here , I am getting wrong user_id in my controller, It should be something like 15 but I am getting my subdomain value subdomain_value

What I am doing wrong here ?

Thanks for your time and advise.

Upvotes: 2

Views: 1454

Answers (1)

Arvind
Arvind

Reputation: 857

Try following code in your controller

 $user_id = $request->route()->parameter('user_id');

You can access the exact value of route variable from the route parameters.

Upvotes: 4

Related Questions