samedi 16 novembre 2019

Multi optional parameters for controller

I need pass 2 optional parameters to controller, in route I have:

Route::get('/products/{start?}/{end?}', 'productsController@index');

In Products controller I have:

public function index($start = NULL, $end = NULL) {
    // ....
}

This works fine if there is passed both of arguments, but how to handle situation, were we need pass only $end parameter? because when passed only one parameter, it always goes to as $start parameter.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire