Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117878682
VerificationCode.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
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
Sun, Apr 5, 10:27 PM (2 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
b4/31/fd74be5d4afec315ee48009da788
Default Alt Text
VerificationCode.php (1 KB)
Attached To
Mode
rK kolab
Attached
Detach File
Event Timeline