Phosphorum\Badges\Badge\GoodReply::has PHP Method

has() public method

Check whether the user already have this badge
public has ( Users $user ) : boolean
$user Phosphorum\Models\Users
return boolean
    public function has(Users $user)
    {
        $has = false;
        $noBountyCategories = $this->getNoBountyCategories();
        $conditions = '(IF(votes_up IS NULL, 0, votes_up) - IF(votes_down IS NULL, 0, votes_down)) >= 5';
        $replies = $user->getReplies([$conditions, 'columns' => 'id', 'order' => 'created_at DESC']);
        foreach ($replies as $reply) {
            $has |= UsersBadges::count(['users_id = ?0 AND badge = ?1 AND type = "C" AND code1 = ?2', 'bind' => [$user->id, $this->getName(), $reply->id]]) == 0;
        }
        return !$has;
    }