public function generateNumber(Order $order = null)
    {
        $date = Carbon::now();

        $number =  sprintf('%s-%s-%s%s%s',
            $this->getYearAndDayHash($date),
            str_pad(base_convert($date->secondsSinceMidnight(), 10, 36), 4, '0', STR_PAD_LEFT),
            str_pad(base_convert($this->getRapidMicroNumber(), 10, 36), 2, '0', STR_PAD_LEFT),
            base_convert(mt_rand(0, 35), 10, 36), //always one char
            ((string)$this->getSlowMicroNumber())[0]
        );

        if ($this->highVariance) {
            $number .= '-'
                . str_pad(base_convert($this->getSlowMicroNumber(), 10, 36), 2, '0', STR_PAD_LEFT)
                . str_pad(base_convert(mt_rand(0, 1295), 10, 36), 2, '0', STR_PAD_LEFT);
        }

        return $this->uppercase ? strtoupper($number) : $number;
    }
public function generateNumber(Order $order = null)
    {
        $date = Carbon::now();

        $number =  sprintf('%s-%s-%s%s%s',
            $this->getYearAndDayHash($date),
            str_pad(base_convert($date->secondsSinceMidnight(), 10, 36), 4, '0', STR_PAD_LEFT),
            str_pad(base_convert($this->getRapidMicroNumber(), 10, 36), 2, '0', STR_PAD_LEFT),
            base_convert(mt_rand(0, 35), 10, 36), //always one char
            ((string)$this->getSlowMicroNumber())[0]
        );

        if ($this->highVariance) {
            $number .= '-'
                . str_pad(base_convert($this->getSlowMicroNumber(), 10, 36), 2, '0', STR_PAD_LEFT)
                . str_pad(base_convert(mt_rand(0, 1295), 10, 36), 2, '0', STR_PAD_LEFT);
        }

        return $this->uppercase ? strtoupper($number) : $number;
    }
public function generateNumber ( Order $ order = null ) { $ date = Carbon :: now ( ) ; $ number = sprintf ( '%s-%s-%s%s%s' , $ this -> getYearAndDayHash ( $ date ) , str_pad ( base_convert ( $ date -> secondsSinceMidnight ( ) , 10 , 36 ) , 4 , '0' , STR_PAD_LEFT ) , str_pad ( base_convert ( $ this -> getRapidMicroNumber ( ) , 10 , 36 ) , 2 , '0' , STR_PAD_LEFT ) , base_convert ( mt_rand ( 0 , 35 ) , 10 , 36 ) , //always one char ( ( string ) $ this -> getSlowMicroNumber ( ) ) [ 0 ] ) ; if ( $ this -> highVariance ) { $ number .= '-' . str_pad ( base_convert ( $ this -> getSlowMicroNumber ( ) , 10 , 36 ) , 2 , '0' , STR_PAD_LEFT ) . str_pad ( base_convert ( mt_rand ( 0 , 1295 ) , 10 , 36 ) , 2 , '0' , STR_PAD_LEFT ) ; } return $ this -> uppercase ? strtoupper ( $ number ) : $ number ; }
Returns an order number for an order with a time + random based hash

┌──────────────────────────────────────────────────────────────────────────────────────────────┐
│ Format is:                                                                                   │
│  - 3 digits: Days since 2000-01-01 (configurable) converted to 36 scale.                     │
│              eg. 2017-12-02: 6545 days => '51t'                                              │
│  - dash                                                                                      │
│  - 4 digits: second of the day in 36 scale, 0 padded (eg. 82300 -> 1ri4)                     │
│  - dash                                                                                      │
│  - 2 digits: microtime digits 4-6 in 36scale, (eg. 271 -> 7j, 240 -> 6o)                     │
│  - 1 digits: random letter 0-z (0-35)                                                        │
│  - 1 digit:  microtime first digit (slowest changing part of microtime)                      │
│  If *high_variance* is enabled:                                                              │
│  - dash                                                                                      │
│  - 2 digits: microtime digits 1-3 in 36scale, (eg. 171 -> 4r)                                │
│  - 2 digits: random 2 chars 00-zz                                                            │
│                                                                                              │
│ N O T E S                                                                                    │
│   - The first part turns into 4 digits long after 2127-09-27                                 │
│                                                                                              │
│ Example 1                                                                                    │
│ =========                                                                                    │
│ ┌───────────────┐                                                                            │
│ │ 4ob-1hau-bzf4 │                                                                            │
│ └───────────────┘                                                                            │
│    Ordering on 2016 aug 3 at 19:11:18 => 4ob-1hau   -  bz f 4                                │
│                                          ▲   ▲         ▲  ▲ ▲                                │
│                                          │   │         │  │ └──── microtime slow first char  │
│                                2016 aug 3┘   └69078sec │  └─ random nr (0-z)                 │
│                                                        │                                     │
│                                    283, microtime rapid┘                                     │
│                                                                                              │
└──────────────────────────────────────────────────────────────────────────────────────────────┘

@param Order $order

@return string
Returns an order number for an order with a time + random based hash