K
K
kos94ok2018-06-06 17:38:24
Laravel
kos94ok, 2018-06-06 17:38:24

How to properly handle Laravel Route parameter?

For example, let's take a route:
Route::get('product/{id}', '[email protected]')
Send the men or woman value to the id parameter.
And we create one more route:
Route::get('product/{id}/{category}', '[email protected]')
How to replace the id parameter with the value of the previous route?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
anlamas, 2018-06-06
@anlamas

public function category(Request $request, $id, $category)
{
     //
}

it is necessary?

E
eg00, 2018-06-07
@eg00

class IndexController extends Controller
{   
 public function product( $id)
    {
    ...
Session::set('previous_id', $id);
    ...
}

public function category($category)
{    
...
if(Session::has('previous_id')) 
    $previous_id= Session::get('previous_id');
... 
}
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question