/** * Save a new comment instance. * * @param Request $request * @return Response */ public function store(Request $request) { // Populate the comment with the request data $comment = new Comment(); $comment->content = Input::get('content'); $comment->post_id = Input::get('post_id'); $comment->user_id = Input::get('user_id'); // Attempt to save the new post to the database. // Error out if this doesn't work if (!$comment->save()) { // Redirect back to the form with the message bag of errors return redirect()->action('PostController@create')->withErrors($comment->getErrors())->withInput(); } // Add the activity to the comment feed $commentFeed = self::$client->feed('comment', $comment->id); $data = ["actor" => Auth::id(), "verb" => 'create', "object" => 'comment', "conent" => $comment->content, "to" => ["user:{$comment->user_id}", "post:{$comment->post_id}"]]; $commentFeed->addActivity($data); // Redirect to the CommentController index action return redirect()->action('CommentController@index'); }