get unique data whose status is active

How can i use activequery for unique validators in my model




['amenityName', 'unique', 'targetClass' => Amenity::className(), 'message' => 'This amenity has already been taken.',

             'when' => function ($model, $attribute) {

               return $model->{$attribute} !== $model->getOldAttribute($attribute);

           },],

in activequery




public function active()

    {  

        return $this->andWhere(['amenityStatus' => '1']);

    } 


    /**

     * @inheritdoc

     * @return Amenity[]|array

     */

    public function all($db = null)

    {

        return parent::all($db);

    }

i want to get unique value of amenityname whose data is active. now im it checking from all data which is not active

ACHIVED


 [['amenityName','amenityStatus'], 'unique', 'targetAttribute' => ['amenityName', 'amenityStatus'], 'targetClass' => Amenity::className(), 'message' => 'This amenity has already been taken.',

             'when' => function ($model, $attribute) {

               return $model->{$attribute} !== $model->getOldAttribute($attribute);

           },],