Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F1841553
VerificationCode.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
VerificationCode.php
View Options
<?php
namespace
App
;
use
App\SignupCode
;
use
Carbon\Carbon
;
use
Illuminate\Database\Eloquent\Model
;
/**
* The eloquent definition of a VerificationCode
*
* @property string $mode
* @property \App\User $user
*/
class
VerificationCode
extends
SignupCode
{
// Code expires after so many hours
public
const
CODE_EXP_HOURS
=
8
;
public
const
SHORTCODE_LENGTH
=
8
;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected
$fillable
=
[
'user_id'
,
'code'
,
'short_code'
,
'mode'
,
'expires_at'
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected
$casts
=
[];
/**
* The user to which this setting belongs.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public
function
user
()
{
return
$this
->
belongsTo
(
'
\A
pp
\U
ser'
,
'user_id'
,
'id'
);
}
/**
* Generate a short code (for human).
*
* @return string
*/
public
static
function
generateShortCode
():
string
{
$code_length
=
env
(
'VERIFICATION_CODE_LENGTH'
,
self
::
SHORTCODE_LENGTH
);
$code_chars
=
env
(
'VERIFICATION_CODE_CHARS'
,
self
::
SHORTCODE_CHARS
);
$random
=
[];
for
(
$i
=
1
;
$i
<=
$code_length
;
$i
++)
{
$random
[]
=
$code_chars
[
rand
(
0
,
strlen
(
$code_chars
)
-
1
)];
}
shuffle
(
$random
);
return
implode
(
''
,
$random
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Aug 25, 3:22 PM (1 d, 6 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
224592
Default Alt Text
VerificationCode.php (1 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment