Phosphorum\Badges\Badge\FamousQuestion::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 = 'categories_id NOT IN (' . join(', ', $noBountyCategories) . ') AND number_views >= 10000';
        $posts = $user->getPosts([$conditions, 'columns' => 'id', 'order' => 'created_at DESC']);
        foreach ($posts as $post) {
            $has |= UsersBadges::count(['users_id = ?0 AND badge = ?1 AND type = "P" AND code1 = ?2', 'bind' => [$user->id, $this->getName(), $post->id]]) == 0;
        }
        return !$has;
    }
FamousQuestion