public static function _GenerateLicenses(Form $form) { $qty = $form->getElementValue('qty'); if (!is_numeric($qty)) { Core::SetMessage('Please set a valid quantity', 'error'); return false; } if ($qty < 1) { Core::SetMessage('Please set a quantity greater than 0', 'error'); return false; } if ($qty > 999) { Core::SetMessage('Quantity limited to 999', 'warning'); $qty = 999; } $expires = new \Core\Date\DateTime(); $expires->modify($form->getElementValue('duration')); $expires = $expires->format('Y-m-d'); for ($i = 0; $i < $qty; $i++) { $license = new PackageRepositoryLicenseModel(); $license->set('password', \Core\random_hex(rand(35, 49))); $license->set('expires', $expires); $license->save(); } Core::SetMessage('Generated ' . $qty . ' license(s)!', 'success'); return '/packagerepositorylicense/admin'; }