為什么我試圖從愿望清單中洗掉產品,我收到 404 錯誤?
在我的 home.php 中,我有這個:
Route::prefix('profile')->middleware(['auth'])->group(function () {
Route::get('', [ProfileController::class, 'index']);
Route::get('/twofactor', [ProfileController::class, 'manageTwoFactor']);
Route::post('/twofactor', [ProfileController::class, 'activeTwoFactor']);
Route::get('/twofactor/phone',[ProfileController::class,'getPhoneNumberVerify'])->name('profile.2fa.phone');
Route::post('/twofactor/phone',[ProfileController::class,'postPhoneNumberVerify']);
Route::get('/orders',[OrderController::class,'index']);
Route::get('/orders/{order}',[OrderController::class,'show'])->name('order.details');
Route::get('/orders/{order}/payment',[OrderController::class,'payment'])->name('profile.order.payment');
Route::resource('/wishlist',WishlistController::class)>except(['show','create','update','edit']);}); //wishlist routes
在我的控制器中,我有這個:
public function destroy(Wishlist $wishlist)
{
$wishlist->delete();
return back();
}
形式:
<div class="flex-grow-one">
<form action="{{route('wishlist.destroy',$wish->product_id)}}"
method="post" id="delete-wish-{{$wish->product_id}}">
@csrf
@method('delete')
</form>
<a href="javascript:" onclick="document.getElementById('delete-wish-
{{$wish->product_id}}').submit();" hljs-string">">
<i hljs-string">"></i></a>
</div>
uj5u.com熱心網友回復:
你的愿望清單應該類似于 /profile/wishlist/{wishlist} 所以在這種情況下洗掉重定向回這個愿望清單但你已經洗掉了它,所以它會顯示 404。你已經顯示可能在那里使用一些索引或退回到另一條路線。
路線('profile.wishlist.index');
然后它將顯示索引,您可以將其配置為顯示所有愿望清單,或者您可以按照自己的方式進行操作。
uj5u.com熱心網友回復:
因為最后你回到上一頁并且上一頁被洗掉了元素和。不再可用
public function destroy(Wishlist $wishlist)
{
$wishlist->delete();
return back();
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/418172.html
標籤:
下一篇:LaravelURL過濾與GET
