public function create(CreatorListener $observer, $data) { $data['user_id'] = Auth::id(); $data['created_at'] = Carbon::now()->toDateTimeString(); $data['updated_at'] = Carbon::now()->toDateTimeString(); $markdown = new Markdown(); $data['body_original'] = $data['body']; $data['body'] = $markdown->convertMarkdownToHtml($data['body']); $data['excerpt'] = Topic::makeExcerpt($data['body']); // Validation $this->form->validate($data); $topic = Topic::create($data); if (!$topic) { return $observer->creatorFailed($topic->getErrors()); } Auth::user()->increment('topic_count', 1); Robot::notify($data['body_original'], 'Topic', $topic, Auth::user()); return $observer->creatorSucceed($topic); }
public function create(CreatorListener $observer, $data) { $data['user_id'] = Auth::id(); $data['body'] = $this->mentionParser->parse($data['body']); $markdown = new Markdown(); $data['body_original'] = $data['body']; $data['body'] = $markdown->convertMarkdownToHtml($data['body']); // Validation $this->form->validate($data); $reply = Reply::create($data); if (!$reply) { return $observer->creatorFailed($reply->getErrors()); } // Add the reply user $topic = Topic::find($data['topic_id']); $topic->last_reply_user_id = Auth::id(); $topic->reply_count++; $topic->updated_at = Carbon::now()->toDateTimeString(); $topic->save(); Auth::user()->increment('reply_count', 1); App::make('Phphub\\Notification\\Notifier')->newReplyNotify(Auth::user(), $this->mentionParser, $topic, $reply); Robot::notify($data['body_original'], 'Reply', $topic, Auth::user()); return $observer->creatorSucceed($reply); }