Question: If I have a route like the following.

```php
Route::post('/user/{id}', 'UserController@my_function');

```

How do I set up the controller function to be like this so I can use the URL parameter and POST request body data? I'd expect it to be similar to the below code, but is this correct?

```php
public function my_function($id, Request $request){}

```

Answer: 
The way you doing is correct according to the laravel docs. 

> 
> If your controller method is also expecting input from a route parameter, list your route arguments after your other dependencies. For example, if your route is defined like so:
> 
> 
> 

```
 Route::put('user/{id}', 'UserController@update');

```

> 
> You may still type-hint the Illuminate\Http\Request and access your id parameter by defining your controller method as follows:
> 
> 
> 

Here is a example using the data you send it:

```
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class UserController extends Controller
{
    /**
     * Update the given user.
     *
     * @param  Request  $request
     * @param  string  $id
     * @return Response
     */
    public function update(Request $request, $id)
    {
       $request->all() // here you're acessing all the data you send it
       $user = User::find($id) // here you're getting the correspondent user from the id you send it

    }
}

```

For more info: [docs](https://laravel.com/docs/5.7/controllers)
its ok but i love passing the id like this when i am returning a view

```
public function my_function(Request $request){
return view('myfile',['id'=>$id]);
}

```