Esempio n. 1
0
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function newComment(CommentFormRequest $request)
 {
     $user_id = Auth::user()->id;
     $comment = new Comment(array('post_id' => $request->get('post_id'), 'content' => $request->get('content'), 'user_id' => $user_id));
     $comment->save();
     return redirect()->back()->with('custom_success', 'Your comment has been created!');
 }
 public function newComment(CommentFormRequest $request)
 {
     $comment = new Comment(array('post_id' => $request->get('post_id'), 'content' => $request->get('content')));
     $comment->save();
     //         return redirect()->back()->with('status', 'Your comment has been created!');
     return redirect()->back()->with('status', 'Your comment has been created!');
 }
Esempio n. 3
0
 public function newComment(CommentFormRequest $request)
 {
     $content = $request->get('content');
     $content = preg_replace('/ /', '&nbsp', $content);
     $content = preg_replace('/\\n/', '<br>', $content);
     $comment = new Comment(array('post_id' => $request->get('post_id'), 'content' => $content));
     $comment->save();
     //        return redirect()->back()->with('status', 'Your comment has been created!');
     return redirect()->to(URL::previous() . "#comment");
 }
 public function newComment(CommentFormRequest $request)
 {
     $id = Auth::user()->id;
     $comment = new Comment(array('user_id' => $id, 'post_id' => $request->get('post_id'), 'content' => $request->get('content')));
     $comment->save();
     /*
             $ticket = TrainingForum::whereid($id)->firstOrFail();
             // return view('training_forum.forum_show', compact('ticket'));
             //for comment
             $comments = $ticket->comments()->get();
             return view('training_forum.forum_show', compact('ticket', 'comments'));
     */
     return redirect()->back()->with('status', 'Your comment has been created!');
 }
Esempio n. 5
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(CommentFormRequest $request)
 {
     $commentbody = $request->get('body');
     $commentbody = nl2br($commentbody);
     $comment = new Comment(array('body' => $commentbody, 'user_id' => Auth::user()->id, 'commentable_id' => $request->get('commentable_id'), 'commentable_type' => 'App\\Story'));
     //$story = new Story($request->all());
     //$comment = Comment::find($id);
     $user = User::find($comment->user_id);
     //return view('stories.show')->with('story', $story)->with('user', $user);
     Auth::user()->comments()->save($comment);
     \Session::flash('flash_message', 'Your Comment has been posted!');
     return redirect('stories/' . $comment->commentable_id . '/')->with('comment', $comment)->with('user', $user);
     //	return redirect('stories/'.$story->id.'/edit');
 }
Esempio n. 6
0
 /**
  * If the user is blocked - he is not able to leave a comment
  * @param CommentFormRequest $request Request
  * @return type Redirect
  */
 public function addComment(CommentFormRequest $request)
 {
     $ip = $request->getClientIp();
     $blacklisted = Firewall::isBlacklisted($ip);
     if ($blacklisted) {
         Flash::warning('Sorry, you have been blocked and you can\'t leave comments right now');
         return Redirect::route('comments');
     } else {
         $newMessage = new Comment();
         $newMessage->comment = $request->get('comment');
         $newMessage->name = $request->get('name');
         $newMessage->email = $request->get('email');
         $newMessage->ip = $ip;
         $newMessage->save();
         Flash::success('Thank you for your opinion!');
         return Redirect::route('comments');
     }
 }