예제 #1
0
 public function addComment(Request $request, $content)
 {
     $this->validate($request, Comment::rules());
     if (Auth::user()->isBanned($content->group)) {
         return Response::json(['status' => 'error', 'error' => 'Zostałeś zbanowany w tej grupie']);
     }
     $comment = new Comment(['text' => Input::get('text')]);
     $comment->user()->associate(Auth::user());
     $comment->content()->associate($content);
     $comment->save();
     $comment = view('comments.widget', compact('comment'))->render();
     return Response::json(['status' => 'ok', 'comment' => $comment]);
 }
예제 #2
0
 public function store(Request $request, $content)
 {
     $this->validate($request, Comment::rules());
     if (user()->isBanned($content->group)) {
         return response()->json(['status' => 'error', 'error' => 'Zostałeś zbanowany w tej grupie']);
     }
     $comment = new Comment();
     $comment->text = request('text');
     $comment->user()->associate(user());
     $comment->content()->associate($content);
     $comment->save();
     return response()->json(['status' => 'ok', '_id' => $comment->getKey(), 'comment' => $comment]);
 }