public function create(array $attributes) { if (!is_null($this->validator)) { $this->validator->with($attributes)->passesOrFail(ValidatorInterface::RULE_CREATE); } $reply = new Reply($attributes); $reply->user_id = Auth::id(); $reply->body = app('markdown')->text($attributes['body']); $reply->body_original = $attributes['body']; $reply->save(); return $reply; }
/** * 发布新的评论. * * @param array $attributes * * @return Reply */ public function store(array $attributes) { if (!is_null($this->validator)) { $this->validator->with($attributes)->passesOrFail(ValidatorInterface::RULE_CREATE); } $reply = new Reply($attributes); $reply->user_id = Auth::id(); $reply->body = app('markdown')->text($attributes['body']); $reply->body_original = $attributes['body']; $reply->save(); $reply->topic()->getQuery()->increment('reply_count'); event(new NewReply($reply, Auth::id(), $reply->topic()->getQuery()->pluck('user_id'))); return $reply; }