Route pattern cannot reference variable name more than once

在用 Laravel Backpack 写一个定制化的 CRUD 页面。例如,一个指定店铺所拥有的商品的 CRUD 页面。

起初路由我是这样写的

CRUD::resource('products-of-store/{store_id}', 'ProductCrudController');

报错

Route pattern "/products-of-store/{store_id}/{{store_id}}" cannot reference variable name "store_id" more than once.

解决方法,Route 调整为

CRUD::resource('store/{store_id}/products', 'ProductCrudController');

即,Route 的最后设置为一个非变量。

出错的原因

我觉得是 resource 会自动将 route 最后的那个单词作为变量,所以出现了报错日志中的变量名重复的问题。

转载于:https://www.cnblogs.com/sgm4231/p/10191187.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值