简释什么维尼修斯·路易斯说。
Route::get('/menu/{category}/{product}/{item}', ['as' => 'named.route' , 'uses' => '[email protected]']);
// to get the actual linke
route('named.route', ['category' => $category->id, 'product' => $product->id, 'item' => $item->id]);
依赖,你可能做不到 - > ID或任何东西,你可能只是通过整个$类,$产品等依赖于你的控制器路由的设置方式。
编辑: 从您的评论,它喜欢像你想是这样的:
class MenuController {
public function lisItem($category_name, $product_name) {
$category = Category::where('name', $category_name)->first(['id']);
$product = Product::where('category_id', $category->id)->where('name', $product_name')->first();
}
}
Route::get('/{category}/{item}', ['as' => 'named.route' , 'uses' => '[email protected]']);
// to get the actual linke
route('named.route', ['category' => $category->id, 'item' => $item->id]);
有可能是一个更好的方式做了查询,但应该为你工作。
对不起,我试图把嗨,但它看起来并不想更新,因为有人射我:D – JroS
你的目的是什么? – trinvh
目的只是将“http:// localhost:8080/menu/homme/bijoux/pendentif”中的网址替换为“http:// localhost:8080/homme/pendentif”,其中homme为{category}, pendentif是{item] – JroS