数据库通知不起作用,但电子邮件通知在laravel中起作用

时间:2019-06-25 18:11:03

标签: laravel-5 notifications

当某人对某个帖子发表评论时,我想在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();

    }

0 个答案:

没有答案