【发布时间】:2017-05-21 00:17:17
【问题描述】:
我将路线定义为
Route::get('roundtables/{name}/tags/store',['as'=>'tags.store','uses'=>'TagController@store','middleware'=>['owner','auth']]);
在我看来,我在这个 url 中有一个表单
<div class="col-md-3">
<div class="well">
{!! Form::open(['route'=>'tags.store','method'=>'GET']) !!}
<h2>New Tags</h2>
{{ Form::label('name','Name') }}
{{ Form::text('name',null,['class'=>'form-control']) }}
{{Form::submit('Create New Tag',['class'=>'btn btn-primary btn-block btn-h1-spacing'])}}
</div>
</div>
我的问题是,如何从 id 为 '1' 的 url 获取 id 并在用户单击提交时传递到表单中。
我的控制器
public function store(Request $request,$name)
{
$this->validate($request,array('name'=>'required|max:255'));
$tag=new Tag;
$tag->name=$request->name;
$tag->roundtable_id=$name;
$tag->save();
Session::flash('success','New Tag was successfully added');
return redirect()->route('tags.index');
}
【问题讨论】:
-
向我们展示您的控制器代码