Laravel5.6(過去バージョンでも問題ないです)
現在Laravelの勉強中で初めての質問になります。よろしくお願いします。
商品ページを3段階で
http://www.teratail.com/teratail/product/ →カテゴリリスト
http://www.teratail.com/teratail/product/?cate=1 →カテゴリ別アイテムリスト
http://www.teratail.com/teratail/product/?id=1 →アイテム詳細
という風にURLは同じ階層のままパラメータ別で違うアクションに飛ばしたいです。
現状下記のように階層を変えてルーティングを書けば動くのですが上のようにするには
どこをどのように書けばよろしいでしょうか?
http://www.teratail.com/teratail/product/
http://www.teratail.com/teratail/product/cate/?cate=1
http://www.teratail.com/teratail/product/item/?id=1
php
1 2web.php 3 4Route::get('product/', 'ProductController@index'); 5Route::get('product/category/', 'ProductController@category'); 6Route::get('product/item/', 'ProductController@item'); 7 8 9ProductController.php 10 11class ProductController extends Controller{ 12 13 public function index(Request $request) 14 { 15 //カテゴリリスト 16 return view('product.index'); 17 } 18 19 public function category(Request $request) 20 { 21 カテゴリ別アイテムリスト 22 return view('product.category'); 23 } 24 25 public function item(Request $request) 26 { 27 アイテム詳細 28 return view('product.item'); 29 } 30 31}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。