带参数的拉拉维尔路线链接不起作用


Laravel route link with parameter not work

在我的路由中有可选参数。 当我单击我的链接时,它会产生问题。它看起来像

http://localhost/my/public/admin/category/sub-create?2

但它将是

http://localhost/my/public/admin/category/sub-create/2

我的路线

     Route::get('sub-create/{cid?}',['as'=>'new_sub_category',
'uses'=>'CategoryController@SubCategoryCreate']);

我的链接

<a href="{{route('new_sub_category', $categoryID)}}"
     class="btn bg-navy btn-flat margin">
    <i class="fa fa-plus-square"></i> Add New Subcategory</a>

遵循这种方式。这将创建正确的路线

{{route('new_sub_category', ['cid'=>$categoryID])}}

<a href="{{route('new_sub_category', ['cid'=>$categoryID])}}"
     class="btn bg-navy btn-flat margin">
    <i class="fa fa-plus-square"></i> Add New Subcategory</a>