My routes/web.php file
$router->group(['prefix' => 'api/v1'], function () use ($router) {
$router->get('post/{string}/comment/{length?}', 'PostController@index');
});
My controller file
public function index($string, $length = 0){
// boy
}
URLs to execute
localhost/project/public/api/v1/post/abcd/comment/1
OR
localhost/project/public/api/v1/post/abcd/comment
I want string and length values in my controller, string is not optional parameter but length is optional if i not provide it it should take 0