Auth::id(), ]); } else { $comment = $initialComment; } $inReplyTo = Arr::get($data, 'inReplyTo'); // specific app might need to store // some extra data along with comment $attributes = Arr::except($data, 'inReplyTo'); if ($inReplyTo) { $attributes['parent_id'] = $inReplyTo['id']; } if (isset($attributes['commentable_type'])) { // track => App\Track $attributes['commentable_type'] = $data['commentable_type']; } $comment->fill($attributes)->save(); $comment->generatePath(); if ( !$initialComment && $inReplyTo && $inReplyTo['user']['id'] !== Auth::id() ) { app(User::class) ->find($inReplyTo['user']['id']) ->notify(new CommentReceivedReply($comment, $inReplyTo)); } return $comment; } }