Created
May 15, 2019 21:13
-
-
Save srph/4d21aeebcb0f9f5ef0573f3a62853707 to your computer and use it in GitHub Desktop.
PHP: Generate invitation codes/licenses strings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Support; | |
use Str; | |
class Helper { | |
/** | |
* e.g., X4345-ZXCA4-S3XYB-3AST1 | |
*/ | |
static public function generateInvitationCode() { | |
$strings = []; | |
for ($i = 0; $i < 5; $i++) { | |
$strings[] = strtoupper(Str::random(5)); | |
} | |
return implode('-', $strings); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment