Skip to content

Instantly share code, notes, and snippets.

@omarkdev
Created May 15, 2017 19:59
Show Gist options
  • Save omarkdev/93ce7023801a2b0e43cdf366cf7a3659 to your computer and use it in GitHub Desktop.
Save omarkdev/93ce7023801a2b0e43cdf366cf7a3659 to your computer and use it in GitHub Desktop.
<?php
public function store(Request $request)
{
// Create a new comment
$comment = Comment::create($request->all());
// Find the author and highlight the comment on your profile
$user = User::find( $request->get('user_id') );
$user->profile->highlightNewComment($comment);
// Author of the post and the users who have already commented
$users = $comment->post->users;
foreach ($user as $user) {
// Notify the user who has a new comment.
Notification::hasNewComment($user, $comment);
}
return ['success' => true];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment