I had defined my route and controller as following
$router->group(['prefix' => 'api/v1'], function ($router) {
$router->group(
['middleware' => 'auth'], function() use ($router) {
$router->get('/order/get-order-status/{order_id}[/{account_id}]'
, [
'uses' => 'Api\V1\OrderController@getOrderStatus'
, 'as' => 'getOrderStatus'
]
);
});
});
following is the function defination
public function getOrderStatus($orderId, $accountId = false)
{
// my code goes here
}
Here the problem is whenever, I skip the optional account_id
from the route, then passed order_id
is assigned to the 2nd parameter of the function i,e. accountId
. If I pass both params then everything is working as expected. I'm just confused whether something is wrong in my configuration or Lumen
itself have some issue with optional route params?
Consider I had triggered http://localhost/lumen/api/v1/order/get-order-status/ORD1234
then ORD1234
is assigned to accountId
and '0' is assigned to orderId