首页 > 解决方案 > 类 Illuminate\Routing\Redirector 的对象无法转换为 int laravel

问题描述

我想在一些操作后重定向用户以使用参数进行路由,我写了这样的东西

  return redirect()-route('purchaseList' , ['shop' => $shopName , 'id' => $productId]);

但是当它重定向时,它给了我这个错误:

类 Illuminate\Routing\Redirector 的对象无法转换为 int

顺便说一句 $shopName 和 $productID 是存在的,问题不是这个

这是我的路线

Route::get('/{shop}/purchase-list/{id}', 'ShopController@purchaseList')->name('purchaseList');

标签: phplaravel

解决方案


您应该更新重定向方法。

return redirect()->route('purchaseList' , ['shop' => $shopName , 'id' => $productId]);

你必须错过>


推荐阅读