guys! i have automatic code number for invoice. the automatic code number is "xx/month/year". i want "xx" in my automatic code number reset to 1 when the year change or every 1 january. this is my code
function noinvoice()
{
$latest = Pengiriman::latest()->first();
$month = date('m');
$year = date('Y');
if (!$latest) {
return '1/' . $month . '/' . $year;
}
$string = preg_replace("/[^0-9\.]/", '', $latest->noinvoice);
return sprintf($string + 1) . '/' . $month . '/' . $year;
}