0

I have the following in my routes

Route::get('c/maintenances/{contractor_user_id}', 'Maintenance\Api\ApiContractorMaintenanceController@index');

is there a way for me to get the /{contractor_user_id} by reading the url?

For example

 $current_url = Request::url();
 dd($current_url);

returns

"http://127.0.0.1:8000/api/c/maintenances/3"

Is there a way to alienate the 3 from the url and return it?

2 Answers 2

3

Use this request()->route('contractor_user_id');

$request->route('parameter_name')., where parameter_name refers to what we called the parameter in the route.

https://www.digitalocean.com/community/tutorials/get-laravel-route-parameters-in-middleware

Sign up to request clarification or add additional context in comments.

Comments

0

You can also use the request() helper

request()->route('parameter_name')

`

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.