Created
October 19, 2016 23:02
-
-
Save apocsve/f29ddaff34af1e585db43311c8ded4ea to your computer and use it in GitHub Desktop.
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
if (empty($this->code)) { | |
$options = [ | |
'length' => 10, | |
'prefix' => 'GCC', | |
'letters' => true, | |
'numbers' => true, | |
'mask' => '-XXXXXXX-XXX' | |
]; | |
$code = GCCodeGenerator::generate($options); | |
$gc = GiftCard::where('code', $code)->first(); | |
while($gc) | |
{ | |
$code = GCCodeGenerator::generate(10, $options); | |
$gc = GiftCard::where('code', $code)->first(); | |
} | |
$this->times_used = 0; | |
$this->code = $code; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment