问题
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