Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F7054527
VerificationCode.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
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
*/
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
Fri, Jun 12, 2:40 AM (3 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
901993
Default Alt Text
VerificationCode.php (1 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment