Route Issue in Anchor Link in Laravel 5.2

折月煮酒 提交于 2019-12-25 18:19:58

问题


I have route defined in the Route.php file like below

Route::get('/SubCategories-List/{categoryID}', 'Skills\Category_Controller@SubCategories');

Below is the code done in Blade for showing list of records.

@foreach($Categories as $Category)
    <tr class="odd pointer">
        <td class=" last">
            <a href="{{Route('SubCategories-List', [$Category->CategoryID])}}">
                 Sub Categories
            </a>
        </td>
    </tr>
@endforeach

I am getting the following error when action method calls the blade

Route [SubCategories-List] not defined.

Am I missing something ?


回答1:


I tried below and worked.

Reference

Route in Route.php

Route::get('/SubCategories-List/{categoryID}', 
           array(
                   'uses' => 'Skills\Category_Controller@SubCategories', 
                   'as'   => 'SubCategories-List'
                )
          );

Anchor link in Blade

{{
    Html::linkRoute('SubCategories-List', 
                  'Sub Categories', 
                  array($Category->CategoryID), 
                  array('style' => 'text-decoration: underline;'))
}}


来源:https://stackoverflow.com/questions/34561624/route-issue-in-anchor-link-in-laravel-5-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!