Cansu Koç
Cansu Koç

Reputation: 11

Laravel get paramater from url in blade

I want to write in blade second parameter of URL

{{ Request::get('urlNumber') }}

I using this but it is not showing parameter in blade.

IN Route: Route::get('/{id}/policydetail/{urlNumber}','MerchantDashboardController@policydetail');

Exam Url:: http://127.0.0.1:8001/backoffice/5896/policydetail/2

Upvotes: 0

Views: 577

Answers (1)

Tim Lewis
Tim Lewis

Reputation: 29288

@brombeer's suggestion of passing the urlNumber param from the Controller to the view is the correct approach, but you can access URL Params via the ->parameter() method:

https://laravel.com/api/8.x/Illuminate/Routing/Route.html#method_parameter.

In your case:

{{ request()->route()->parameter('urlNumber') }}

The request()->get() method you're trying to use is for getting a value from a Query String, like ?urlNumber=123. Url Parameters {urlNumber} are not the same as Query String parameters, so that code will not work here.

Upvotes: 3

Related Questions