How to access the Laravel's route parameters outside of the controller?

Laravel: How to access the Laravel's route parameters outside of the controller?

If you want to read the route params (that are normally passed to the controller) from somewhere else, you can use Route::current()->parameters().

For example:

  1. $request_params = Route::current()->parameters();

webdevetc profile pic
webdevetc

I am a 29 year old backend web developer from London, mostly focusing on PHP and Laravel lately. This (webdevetc.com) is my blog where I write about some web development topics (PHP, Laravel, Javascript, and some server stuff). contact me here.



More...


Comments and discussion about How to access the Laravel's route parameters outside of the controller?

Found this interesting? Maybe you want to read some more in this series?

Or see other topics in the Laravel language

Or see other languages/frameworks:
PHP Laravel Composer Apache CentOS and Linux Stuff WordPress General Webdev and Programming Stuff JavaScript
Or see random questions

What are route patterns in Laravel?

Push vs Pop vs Shift vs Unshift

How to have a whitelist of IP addresses that can access files in .htaccess

How to select all rows for a certain month (or day, year or time), using Eloquent

How to check if a (blade) view file exists

How to do comments in Blade files?

How to set up custom error pages in .htaccess for your Apache server (ErrorDocument)

How to block an IP address in .htaccess

How to replace whitespace with a single space

What is the difference between ( for ... in ) and ( for ... of ) in javascript?