我在web.php的开发人员组中有这条路线
Route::get('{store}/products/{products}/variants', [
'as' => 'variants.create',
'uses' => 'VariantsController@create',
]);
Route::post('{store}/products/{products}/variants', [
'as' => 'variants.store',
'uses' => 'VariantsController@store',
]);其中{store}是段塞,{products}是uuid。
现在我的VariantsController@create:
public function create($store, $id)
{
$store = Store::where('slug', $store)->firstOrFail();
$product = $store->products()->findOrFail($id);
return view('devoptions.products.variants', compact('store'));
}还有我的variants.blade.php
<div class="container">
<div class="row">
{!! Form::open([ 'route' => ['developer.variants.store', $store->slug],
'method' => 'POST' ]) !!}
<div class="col-sm-12">
<div class="page-header">
//more code here我发现了一个错误:
缺少路由所需的参数: developer.variants.store。(浏览: /Users/Kit/nowna-core-php-api/resources/views/devoptions/products/variants.blade.php)
我尝试过通过$product,但我不知道如何通过,即使我尝试,它也不起作用。请帮帮忙。
编辑:我尝试传递另一个参数:
{!! Form::open([ 'route' => ['developer.variants.store', $store->slug, $product->uuid],
'method' => 'POST' ]) !!}但现在它给了我另一个错误:
未定义变量:存储(视图: /Users/Sample/project/resources/views/devoptions/products/variants.blade.php) )
发布于 2018-08-28 13:55:32
在第二个param和$product->uuid中缺少[],尝试如下:
{!! Form::open([ 'route' => ['developer.variants.store', [$store->slug, $product->uuid]],
'method' => 'POST' ]) !!}发布于 2018-08-28 10:51:20
试试这个:
{!! Form::open([ 'route' => ['developer.variants.store', $store->slug, $product->uuid],
'method' => 'POST' ]) !!}https://stackoverflow.com/questions/52055573
复制相似问题