Route::middleware(['auth'])->group(function () {
Route::get('/shop/products/create', [ShopProductController::class, 'create'])->name('shop.products.create');
Route::get('/shop/products', [ShopProductController::class, 'index'])->name('shop.products.index');
Route::post('/shop/products', [ShopProductController::class, 'store'])->name('shop.products.store');
Route::get('/shop/products/{product}/edit', [ShopProductController::class, 'edit'])->name('shop.products.edit');
Route::get('/shop/products/{product}', [ShopProductController::class, 'show'])->name('shop.products.show');
Route::put('/shop/products/{product}', [ShopProductController::class, 'update'])->name('shop.products.update');
Route::get('/shop/create', [ShopController::class, 'create'])->name('shop.create');
Route::get('/shop', [ShopController::class, 'index'])->name('shop.index');
Route::post('/shop', [ShopController::class, 'store'])->name('shop.store');
Route::get('/shop/edit', [ShopController::class, 'edit'])->name('shop.edit');
Route::put('/shop', [ShopController::class, 'update'])->name('shop.update');
});上で、/shop/products/create がどうしても404になる。
理解し難いんだけど、/shop/products/{product}’ これとバッティングするらしい。
php artisan route:list | grep products
これで見てもちゃんと出てくる。
????
Route::get(‘/shop/products/{product}’, [ShopProductController::class, ‘show’])->name(‘shop.products.show’)->whereNumber(‘product’);
と
->whereNumber(‘product’);
これをつけることで解決した。