我认为我的问题是错误的,我将在此澄清整个主题。 我有1个表格的2个按钮,我已经搜索过这个主题了。 所以这里是: 我有2个按钮,另一个按钮将转到此处,另一个按钮将转到
public function store(Request $request)
{
request()->validate([
'name' => 'required',
'note' => 'required',
'ingredientid' => 'required',
]);
Recipe::create($request->all());
return redirect()->route('recipe.index')
->with('success','Recipe added to the list successfully.');
}
public function addviewing()
{
request()->validate([
'id' => 'required',
'name' => 'required',
]);
Viewingredient::create([
'id' => $request->id,
'name' => $request->name,
]);
return redirect()->route('recipe.form')
->with('success','Ingredient Added Successfully!');
}
这是两个按钮:
<div class="col-xs-12 col-sm-12 col-md-12 text-center">
<button type="submit" class="btn btn-primary">Add Ingredient</button>
</div>
<div class="col-xs-12 col-sm-12 col-md-12 text-center">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
但是当我点击添加成分时它什么也没做。