src/Model/Invoice.php
public function generateValidRef(): string
    {
        Factory::helper('string');

        $oDb  = Factory::service('Database');
        $oNow = Factory::factory('DateTime');

        do {

            $sRef = $oNow->format('Ym') . '-' . strtoupper(random_string('alnum'));
            $oDb->where('ref', $sRef);
            $bRefExists = (bool) $oDb->count_all_results($this->table);

        } while ($bRefExists);

        return $sRef;
    }
public function generateValidRef(): string
    {
        Factory::helper('string');

        $oDb  = Factory::service('Database');
        $oNow = Factory::factory('DateTime');

        do {

            $sRef = $oNow->format('Ym') . '-' . strtoupper(random_string('alnum'));
            $oDb->where('ref', $sRef);
            $bRefExists = (bool) $oDb->count_all_results($this->table);

        } while ($bRefExists);

        return $sRef;
    }
public function generateValidRef ( ) : string { Factory :: helper ( 'string' ) ; $ oDb = Factory :: service ( 'Database' ) ; $ oNow = Factory :: factory ( 'DateTime' ) ; do { $ sRef = $ oNow -> format ( 'Ym' ) . '-' . strtoupper ( random_string ( 'alnum' ) ) ; $ oDb -> where ( 'ref' , $ sRef ) ; $ bRefExists = ( bool ) $ oDb -> count_all_results ( $ this -> table ) ; } while ( $ bRefExists ) ; return $ sRef ; }
Generates a valid invoice ref

@return string
@throws FactoryException
Generates a valid invoice ref