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 some ways you can log debug messages and data in JS?

How to find an item by Primary Key in Eloquent, or throw a ModelNotFoundException exception if it isn't found?

What are route patterns in Laravel?

How do you access the php://input stream?

How to Extract Query String (from a URL) Into an Associative Array in PHP

How to create random numbers in JS?

How to increment a value in the database

What is the difference between var, let and const in Javascript?

How to use Anonymous classes in PHP 7?

What is camel case?