Ejemplo n.º 1
0
 protected function createFakeCommentReply(Comment $comment)
 {
     $comment->replies()->create(['created_at' => $this->faker->dateTimeThisDecade, 'text' => $this->faker->text(512), 'user_id' => $this->getRandomUser()->getKey()]);
 }
Ejemplo n.º 2
0
 /**
  * Add new reply to given Comment object.
  *
  * @param  Request  $request
  * @param  Comment  $parent
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function addReply(Request $request, $parent)
 {
     $this->validate($request, CommentReply::rules());
     $content = $parent->content;
     if (Auth::user()->isBanned($content->group)) {
         return Response::json(['status' => 'error', 'error' => 'Zostałeś zbanowany w tej grupie']);
     }
     $comment = new CommentReply(['text' => Input::get('text')]);
     $comment->user()->associate(Auth::user());
     $parent->replies()->save($comment);
     $replies = view('comments.replies', ['replies' => $parent->replies])->render();
     return Response::json(['status' => 'ok', 'replies' => $replies]);
 }