我正在尝试从我的blade.php中传递多个参数
{!! Form::open([ 'route' => ['developer.variants.store', $store->slug, $product->uuid],
'method' => 'POST' ]) !!}
它给了我错误:
未定义变量:存储(查看:/directory/products/variants.blade.php)
这是我在控制器中创建的内容:
public function create($store, $id)
{
$store = Store::where('slug', $store)->firstOrFail();
$products = $store->products()->findOrFail($id);
return view('devoptions.products.variants', compact('store, products'));
}
我该怎么办?传递多个参数的正确方法是什么?
编辑:这是我的整个variants.blade.php
@extends('layouts.admin-default')
@section('content')
<div class="container">
<div class="row">
{!! Form::open([ 'route' => ['developer.variants.store', $store->slug, $product->uuid],
'method' => 'POST' ]) !!}
<div class="col-sm-12">
<div class="page-header">
<h1>Add Variant</h1>
</div>
</div>
<div class="col-sm-12">
<div class="panel panel-default">
<div class="panel-body">
<div class="col-sm-12">
<h2>Variants</h2>
</div>
<div class="form-group">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-6">
<label for="name">Name</label>
<input class="form-control" type="text" id="name" name="name">
</div>
<div class="col-sm-6">
<label for="name">Quantity</label>
<input class="form-control" type="number" id="slug" name="slug">
</div>
<br>
<div class="col-sm-6">
<br>
<label for="retail_price">Retail Price</label>
<div class="form-group">
<div class="row">
<div class="col-sm-4">
<input class="form-control" type="text" id="price_currency" name="price_currency" value="PHP">
</div>
<div class="col-sm-8">
<input class="form-control" type="number" id="retail_price" name="retail_price">
</div>
</div>
</div>
</div>
<div class="col-sm-6">
<br>
<label for="acquisition_price">Acquisition Price</label>
<input class="form-control" type="text" id="acquisition_price" name="acquisition_price">
</div>
<br>
<button class="btn btn-primary pull-right">
<i class="fa fa-check"></i> Save Product
</button>
</div>
</div>
{!! Form::close() !!}
</div>
@endsection
答案 0 :(得分:2)
不正确的语法compact()
return view('devoptions.products.variants', compact('store', 'products'));
答案 1 :(得分:0)
{!! Form::open([ 'route' => ['developer.variants.store', $store->slug, $products->uuid], 'method' => 'POST' ]) !!}