Reputation: 8801
I'm getting this error:
NotFoundHttpException in RouteCollection.php line 161:
when I make this request from my template:
<a href="{{ route('getprodpage', ['id' => $product->id, 'entity' => 'incentive']) }}">
This is my routes.php
Route::get('getprodpage/{id}/{entity?}', [
'as' => 'getprodpage', 'uses' => 'ProductController@countProductClicks'
]);
What is wrong with this?
EDIT
This is how I'm doing with nested resource:
routes.php
Route::get('product/{id}/entity/{entity}', [
'as' => 'getprodpage', 'uses' => 'ProductController@countProductClicks'
]);
Blade template request:
<a href="{{ route('getprodpage', ['id' => $product->id, 'entity' => 'incentive']) }}">
Upvotes: 1
Views: 56
Reputation: 164
It is not allowed to make route 'getprodpage/{id}/{entity?}'
Try with: https://laravel.com/docs/5.1/controllers#restful-resource-controllers Example:
Route::get('products/{id}', ['as' => 'ShowProduct', 'uses' => 'ProductController@show']);
Route::get('products/{id}/categories/{catId}', ['as' => 'ShowProductCategory', 'uses' => 'ProductCategoryController@show']);
Then in your CategoryController@show method you get two variables:
show($productId, $categoryId){
}
Upvotes: 1