public function categoryId(array $values)
    {
        $count = count($values);
        $ids = array_filter($values, 'ctype_digit');

        if ($count != count($ids)) {
            return $this->translation->text('@field has invalid value', array(
                '@field' => $this->translation->text('Condition')));
        }

        $existing = array_filter($values, function ($category_id) {
            $category = $this->category->get($category_id);
            return isset($category['category_id']);
        });

        if ($count != count($existing)) {
            return $this->translation->text('@name is unavailable', array(
                '@name' => $this->translation->text('Category')));
        }

        return true;
    }
public function categoryId(array $values)
    {
        $count = count($values);
        $ids = array_filter($values, 'ctype_digit');

        if ($count != count($ids)) {
            return $this->translation->text('@field has invalid value', array(
                '@field' => $this->translation->text('Condition')));
        }

        $existing = array_filter($values, function ($category_id) {
            $category = $this->category->get($category_id);
            return isset($category['category_id']);
        });

        if ($count != count($existing)) {
            return $this->translation->text('@name is unavailable', array(
                '@name' => $this->translation->text('Category')));
        }

        return true;
    }
public function categoryId ( array $ values ) { $ count = count ( $ values ) ; $ ids = array_filter ( $ values , 'ctype_digit' ) ; if ( $ count != count ( $ ids ) ) { return $ this -> translation -> text ( '@field has invalid value' , array ( '@field' => $ this -> translation -> text ( 'Condition' ) ) ) ; } $ existing = array_filter ( $ values , function ( $ category_id ) { $ category = $ this -> category -> get ( $ category_id ) ; return isset ( $ category [ 'category_id' ] ) ; } ) ; if ( $ count != count ( $ existing ) ) { return $ this -> translation -> text ( '@name is unavailable' , array ( '@name' => $ this -> translation -> text ( 'Category' ) ) ) ; } return true ; }
Validates the category ID condition
@param array $values
@return boolean|string
Validates the category ID condition