public function storeReply(Request $request, $comment) { $this->validate($request, CommentReply::rules()); $content = $comment->content; if (user()->isBanned($content->group)) { return response()->json(['status' => 'error', 'error' => 'Zostałeś zbanowany w tej grupie']); } $reply = new CommentReply(); $reply->text = request('text'); $reply->user()->associate(user()); $comment->replies()->save($comment); return response()->json(['status' => 'ok', '_id' => $reply->getKey(), 'comment' => $reply]); }
public function onCommentReplyEdit(CommentReply $comment) { $notification = $comment->notifications()->first(); $this->updateNotificationTargets($notification, $comment->text_source); }
/** * @param string $id * @param string $type * @return \Illuminate\Database\Eloquent\Collection|\Illuminate\Database\Eloquent\Model */ private function getObject($id, $type) { $id = \Hashids::decode($id); $id = current($id); switch ($type) { case 'content': return Content::findOrFail($id); case 'related': return ContentRelated::findOrFail($id); case 'entry': return Entry::findOrFail($id); case 'entry_reply': return EntryReply::findOrFail($id); case 'comment': return Comment::findOrFail($id); case 'comment_reply': return CommentReply::findOrFail($id); } }
public function editComment(Request $request) { $class = Input::get('type') == 'comment' ? Comment::class : CommentReply::class; $id = hashids_decode($request->input('id')); $comment = $class::findOrFail($id); if (!$comment->canEdit()) { app()->abort(403, 'Access denied'); } $this->validate($request, CommentReply::rules()); $comment->update(Input::only('text')); return Response::json(['status' => 'ok', 'parsed' => $comment->text]); }