File: /home/imensosw/www/mpl.imenso.co/app/Listeners/RemoveLikeFromComment.php
<?php
namespace App\Listeners;
use App\Events\UserUnlikesCommentOnPost;
use App\Models\Like;
class RemoveLikeFromComment
{
/**
* Create the event listener.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Handle the event.
*
* @param UserUnlikesCommentOnPost $event
* @return void
*/
public function handle(UserUnlikesCommentOnPost $event)
{
$like = Like::where('user_id', $event->liker->id)
->where('likeable_id', $event->comment->id)
->where('likeable_type', 'App\Comment')
->first();
$like->remove();
}
}