public function store(Request $request)
{
$inputs = $request->all();
$validator = Validator::make($inputs, ['post_id' => 'required|numeric', 'slug' => 'required|max:100|exists:posts,slug,id,' . $inputs['post_id'], 'parent' => 'required|numeric', 'name' => 'required|max:30', 'email' => 'required|email|max:100', 'blog' => 'required|url|max:100', 'origin' => 'required', 'captcha' => 'required|min:4|max:4']);
if ($validator->fails() || $inputs['captcha'] !== session('captcha')) {
return redirect('/posts/' . $inputs['slug'] . '#comment-form')->withErrors($validator)->withInput($inputs);
}
$this->comment->store($inputs);
return redirect('/posts/' . $inputs['slug'] . '#comments')->with('ok', 'comment successfully.');
}