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;
    }