david19
2 months ago
164
4
Laravel

URL with RouteKeyName and Eloquent

Posted 2 months ago by david19

Hello Team, My url for the single view works fine with RouteKey. This works for me:

Route::get('/shop/{category}/{product}', 'Shop\Product\[email protected]')->name('guest.shop.product.product');
public function product(Category $category, Product $product)
{

    return view('guest.shop.product.product',compact('product','category'));

}

I can see my view here: This works! http://localhost/shop/water/smoke-intro

But now i will put my id before. This:

Route::get('/shop/{id}/{category}/{product}

How i can use Eloquent with my setup? I tryed many thinks, but it doesnt work. Many thanks for help.

Please sign in or create an account to participate in this conversation.