【发布时间】:2019-01-31 19:15:44
【问题描述】:
我的控制器无法读取“样本”是商店而不是产品。 我的 web.php 上有这条路线
Route::get('{store}/products/{products}/edit', [
'as' => 'store.products.edit',
'uses' => 'ProductsController@edit',
function($store) {
$store = App\Models\Store::where('slug', $store)->firstOrFail();
}
]);
这是我的 ProductsController@edit
public function edit($id)
{
$product = Product::findOrFail($id);
return view('view here', compact('product'));
}
当我运行网址时:http://127.0.0.1:8000/sample/products/022fe902-7f4d-4db1-b562-04a7eb9f5a68/edit
其中 sample 是 {store},022fe902-7f4d-4db1-b562-04a7eb9f5a68 是 {product}
我收到此错误:
没有模型 [App\Models\Product] 示例的查询结果
在我的查询中:
select * from
productswhereproducts.uuid= 'sample' limit 1
【问题讨论】:
标签: php laravel laravel-5 laravel-routing