@param Model $likedBy

@return bool
485191
public function dislike(Model $likedBy): bool
    {
        if (!$like = $this->getLikedRecord($likedBy)) {
            return false;
        }

        $like->delete();

        return (bool) $this->decrementCounter();
    }
694759
public function getLikes()
    {
        $app = App::getInstance();

        if (!$this->likes) {
            $sql = $app['safesql']->query(
                "SELECT
    SUM(likes)
    FROM `comment`
    WHERE user='%s'
    AND `active`=1
    AND deleted=0",
                array(
                    $this->getUser(),
                ));
            $this->likes = $app['db']->get_var($sql);
        }
        return $this->likes;
    }
1132043
public function likeToggle($userId = null)
    {
        app(LikeableServiceContract::class)->toggleLikeOf($this, LikeType::LIKE, $userId);
    }
651711
def liked(self):
        
        if self.is_logged_in_user: return False
        classes = self._liked_xpb.one_(self.profile_tree).attrib['class'].split()
        return 'liked' in classes
527533
public function where($parameter, $value)
    {
        if (! $this->verify($parameter, $value)) {
            return true;
        }

        $this->search = $this->search
            ->where($parameter, 'LIKE', '%' . $value . '%');
    }
366885
public function removeLikeCountersOfType($likeableType, $type = null)
    {
        if (class_exists($likeableType)) {
            /** @var \Cog\Likeable\Contracts\Likeable $likeable */
            $likeable = new $likeableType;
            $likeableType = $likeable->getMorphClass();
        }

        /** @var \Illuminate\Database\Eloquent\Builder $counters */
        $counters = app(LikeCounterContract::class)->where('likeable_type', $likeableType);
        if (!is_null($type)) {
            $counters->where('type_id', $this->getLikeTypeId($type));
        }
        $counters->delete();
    }
532641
public function collectDislikersOf(LikeableContract $likeable)
    {
        $userModel = $this->resolveUserModel();

        $likersIds = $likeable->dislikes->pluck('user_id');

        return $userModel::whereKey($likersIds)->get();
    }
1275672
public function liked($userId=null)
	{
		if(is_null($userId)) {
			$userId = $this->loggedInUserId();
		}
		
		return (bool) $this->likes()
			->where('user_id', '=', $userId)
			->count();
	}
1077902
def unlike(likeable)
    	if @@likeable_model_names.include? likeable.class.to_s.downcase
    		likeable.likers.delete self
    		self.save
    	else 
    		false
    	end
    end
1019906
public function created(LikeContract $like)
    {
        if ($like->type_id == LikeType::LIKE) {
            event(new ModelWasLiked($like->likeable, $like->user_id));
            app(LikeableServiceContract::class)->incrementLikesCount($like->likeable);
        } else {
            event(new ModelWasDisliked($like->likeable, $like->user_id));
            app(LikeableServiceContract::class)->incrementDislikesCount($like->likeable);
        }
    }
829788
def likes_count(obj):
    
    return Like.objects.filter(
        receiver_content_type=ContentType.objects.get_for_model(obj),
        receiver_object_id=obj.pk
    ).count()
1117727
public function isFavorite()
    {
        $favoriteProduct = FavoriteProduct::find()
            ->where(['product_id' => $this->id, 'user_id' => \Yii::$app->user->id])->one();
        if (!empty($favoriteProduct)) return true;
        else return false;
    }
914280
public function isOwnedBy(Model $owner)
    {
        if ( ! $this->hasOwner())
        {
            return false;
        }

        return ($owner->getKey() === $this->owner->getKey());
    }
966633
protected function isAllowed($providedPermission, Model $entity)
    {
        foreach ($this->getPermissions() as $permission) {
            if ($permission->model != '' && get_class($entity) == $permission->model
                && ($permission->id == $providedPermission || $permission->slug === $providedPermission)
            ) {
                return true;
            }
        }

        return false;
    }
908267
public function removeModelLikes(LikeableContract $likeable, $type)
    {
        app(LikeContract::class)->where([
            'likeable_id' => $likeable->getKey(),
            'likeable_type' => $likeable->getMorphClass(),
            'type_id' => $this->getLikeTypeId($type),
        ])->delete();

        app(LikeCounterContract::class)->where([
            'likeable_id' => $likeable->getKey(),
            'likeable_type' => $likeable->getMorphClass(),
            'type_id' => $this->getLikeTypeId($type),
        ])->delete();
    }
1250386
public static function likeButton($id)
    {
        if (! is_user_logged_in()) {
            return;
        }

        $likes = get_comment_meta($id, '_likes', true);

        if (empty($likes) || is_array($likes) == false) {
            $count = 0;
        } else {
            $count = count($likes);
        }

        $classes = array('like-button');

        if (is_array($likes) == true && in_array(get_current_user_id(), $likes)) {
            $classes[] = 'active';
        }

        $output = '<a class="' . implode(' ', $classes) . '" href="javascript:void(0)" data-comment-id="' . $id . '">';
        $output .= '<span id="like-count">' . $count . '</span>';
        $output .= '</a>';

        return $output;
    }
1141927
public function liked($userId = null)
    {
        return app(LikeableServiceContract::class)->isLiked($this, LikeType::LIKE, $userId);
    }