I wanted to make a notification system in laravel when someone comment on a post the owner that post recieves a notification regarding the comment
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();
}
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire