当某人对某个帖子发表评论时,我想在laravel中建立一个通知系统,该帖子的所有者收到有关该评论的通知
Contoller
public function store(Request $request)
{
$comment = new Comment;
$comment->user_id = Auth::id();
$comment->post_id = $request->post_id;
$comment->body = $request->body;
$comment->save();
$c = Comment::where('id',$comment->id)->with('user')->first();
broadcast(new NewComment($c));//->toOthers();
$post = Post::find($request->post_id);
$user = User::find($post->user->id);
Notification::send($user, new CommentToPost($c));
return $c->toJson();
}