我无法弄清楚我的创建视图有什么问题.我需要提交按钮将我重定向到我的节目视图,以便我可以看到所有创建的标签.以下是创建标记,显示标记然后存储标记的路线:
Route::get('/tags/create', ['uses' => 'TagController@create', 'as' => 'tags.create']); // Allows you to create a new tag
Route::post('/postTags', ['uses' => 'TagController@store', 'as' => 'postTags']); // Place where all the tags are stored
Route::get('/tag/show', ['uses' => 'TagController@show', 'as' => 'tags.show']); // Shows you all the existing tags
Run Code Online (Sandbox Code Playgroud)
这是我的标签控制器:
public function create()
{
$tag = new Tag();
return view('tags.create', compact('tag'));
}
public function store(Request $request)
{
$this->validate($request, [
'name' => 'required',
]);
$tag = new Tag;
$tag->name = $request['name'];
$tag->save();
return redirect()->route("tags.show");
} …Run Code Online (Sandbox Code Playgroud)