function invoiceNumber() { $latest = AppOrder::latest()->first(); if (! $latest) { return 'arm0001'; } $string = preg_replace("/[^0-9.]/", '', $latest->invoice_number); return 'arm' . sprintf('%04d', $string+1); }