/** * @param Request $request * @param Entry $entry * * @return \Symfony\Component\HttpFoundation\Response */ public function storeReply(Request $request, $entry) { $this->validate($request, EntryReply::rules()); if (user()->isBanned($entry->group)) { return response()->json(['status' => 'error', 'error' => 'Użytkownik został zbanowany w wybranej grupie.'], 400); } $reply = new EntryReply(); $reply->text = request('text'); $reply->user()->associate(user()); $entry->replies()->save($reply); return response()->json(['status' => 'ok', '_id' => $reply->getKey(), 'reply' => $reply]); }
public function editEntry(Request $request) { $id = hashids_decode($request->input('id')); $class = $request->input('type') == 'entry_reply' ? EntryReply::class : Entry::class; $entry = $class::findOrFail($id); if (!$entry->canEdit()) { return Response::json(['status' => 'error', 'error' => 'Pojawiła się już odpowiedź na twój wpis.']); } $this->validate($request, EntryReply::rules()); $entry->text = Input::get('text'); $entry->save(); return Response::json(['status' => 'ok', 'parsed' => $entry->text]); }
public function onEntryReplyEdit(EntryReply $entry) { $notification = $entry->notifications()->first(); $this->updateNotificationTargets($notification, $entry->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 onNewEntryReply(EntryReply $reply) { $arrayEntry = $reply->toArray(); $additionalData = array('hashId' => $reply->hashId(), 'avatarPath' => $reply->user->getAvatarPath(), 'entryUrl' => $reply->getURL()); Pusher::trigger('entry.' . $reply->parent->hashId(), 'new-reply', array_merge($arrayEntry, $additionalData)); }