laravel invoice number generator

49

function invoiceNumber()
{
    $latest = App\Order::latest()->first();

    if (! $latest) {
        return 'arm0001';
    }

    $string = preg_replace("/[^0-9\.]/", '', $latest->invoice_number);

    return 'arm' . sprintf('%04d', $string+1);
}

Comments

Submit
0 Comments