laravel 5.2 How to get route parameter in blade? laravel 5.2 How to get route parameter in blade? php php

laravel 5.2 How to get route parameter in blade?


I'm not sure what you mean. If you're trying to construct the route in a Blade template, use

<a href="{{ route('blog.by.slug', ['slug' => 'someslug']) }}">...</a>

If you're trying to access the given parameter, I would suggest passing it from the controller:

// CmsControllerpublic function show($slug){    // other stuff here    return view('someview', compact('slug'));}// someview.blade.php{{ $slug }}

And if you really need to access the parameter from the view without first sending it from the controller... you really shouldn't, but you can use the facade:

{{ Request::route('slug') }}


If you want to get the parameters without using the controller method

{{dd(request()->route()->parameters)}}


In Laravel 8, you can simply use request()->route('parameter_name').