Phosphorum\Badges\Badge\GoodReply::canHave PHP Метод

canHave() публичный Метод

Check whether the user can have the badge
public canHave ( Users $user ) : boolean
$user Phosphorum\Models\Users
Результат boolean
    public function canHave(Users $user)
    {
        $ids = [];
        $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, posts_id', 'order' => 'created_at DESC']);
        foreach ($replies as $reply) {
            $have = UsersBadges::count(['users_id = ?0 AND badge = ?1 AND type = "C" AND code1 = ?2', 'bind' => [$user->id, $this->getName(), $reply->id]]);
            if (!$have) {
                $ids[] = [$reply->posts_id, $reply->id];
            }
        }
        return $ids;
    }