src/Service/Emailer.php
protected function generateReference($exclude = [])
    {
        $oDb = Factory::service('Database');

        do {

            $refOk = false;

            do {

                $ref = strtoupper(random_string('alnum', 10));
                if (array_search($ref, $exclude) === false) {
                    $refOk = true;
                }

            } while (!$refOk);

            $oDb->where('ref', $ref);
            $result = $oDb->get($this->sTable);

        } while ($result->num_rows());

        return $ref;
    }
protected function generateReference($exclude = [])
    {
        $oDb = Factory::service('Database');

        do {

            $refOk = false;

            do {

                $ref = strtoupper(random_string('alnum', 10));
                if (array_search($ref, $exclude) === false) {
                    $refOk = true;
                }

            } while (!$refOk);

            $oDb->where('ref', $ref);
            $result = $oDb->get($this->sTable);

        } while ($result->num_rows());

        return $ref;
    }
protected function generateReference ( $ exclude = [ ] ) { $ oDb = Factory :: service ( 'Database' ) ; do { $ refOk = false ; do { $ ref = strtoupper ( random_string ( 'alnum' , 10 ) ) ; if ( array_search ( $ ref , $ exclude ) === false ) { $ refOk = true ; } } while ( ! $ refOk ) ; $ oDb -> where ( 'ref' , $ ref ) ; $ result = $ oDb -> get ( $ this -> sTable ) ; } while ( $ result -> num_rows ( ) ) ; return $ ref ; }
Generates a unique reference for an email, optionally exclude strings

@param  array $exclude Strings to exclude from the reference

@return string
@throws \Nails\Common\Exception\FactoryException
Generates a unique reference for an email optionally exclude strings