public function createComment(Sample $sample, Request $request) { $input = $request->all(); $body = $input['body']; $rules = ['body' => 'required|min:2']; $validator = Validator::make($input, $rules); if ($validator->fails()) { return back()->withInput()->withErrors($validator); } $user = Sentinel::getUser()->id; $comment = new Comment(); $comment->body = $body; $comment->user_id = $user; $comment->commentable_id = $sample->id; if ($sample->comments()->save($comment)) { return back()->with('success', trans('validation.comment_success')); } else { return back()->withInput()->with('fail', trans('validation.error')); } }