public function store(Request $request)
{
// dd($request);
//form validation
$validatedAttributes = $this->validate($request,[
'title' => 'required|max:60',
'slug' => 'required|min:5|max:255|alpha_dash|unique:posts,slug',
'category_id' => 'required|integer',
'body' => 'required'
]);
// store into database
$Post = Post::create($validatedAttributes);
$Post->tags()->sync($request->tags);
Session::flash('success', 'The Blog Post was Successfully save');
// to redirect to other page
return redirect()->route('post.show',$Post->id);
}
2条答案
按热度按时间zpgglvta1#
对于存储数据,请使用
有关更新,请使用
此处显示详细信息
也在这里
iszxjhcz2#
请尝试以下内容