Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2397600
SignupCode.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
SignupCode.php
View Options
<?php
namespace
App
;
use
Carbon\Carbon
;
use
Illuminate\Database\Eloquent\Model
;
/**
* The eloquent definition of a SignupCode.
*
* @property string $code
* @property array $data
* @property \Carbon\Carbon $expires_at
* @property string $short_code
*/
class
SignupCode
extends
Model
{
public
const
SHORTCODE_LENGTH
=
5
;
public
const
CODE_LENGTH
=
32
;
// Code expires after so many hours
public
const
CODE_EXP_HOURS
=
24
;
/**
* The primary key associated with the table.
*
* @var string
*/
protected
$primaryKey
=
'code'
;
/**
* Indicates if the IDs are auto-incrementing.
*
* @var bool
*/
public
$incrementing
=
false
;
/**
* The "type" of the auto-incrementing ID.
*
* @var string
*/
protected
$keyType
=
'string'
;
/**
* Indicates if the model should be timestamped.
*
* @var bool
*/
public
$timestamps
=
false
;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected
$fillable
=
[
'code'
,
'short_code'
,
'data'
,
'expires_at'
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected
$casts
=
[
'data'
=>
'array'
];
/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected
$dates
=
[
'expires_at'
];
/**
* Check if code is expired.
*
* @return bool True if code is expired, False otherwise
*/
public
function
isExpired
()
{
// @phpstan-ignore-next-line
return
$this
->
expires_at
?
Carbon
::
now
()->
gte
(
$this
->
expires_at
)
:
false
;
}
/**
* Generate a short code (for human).
*
* @return string
*/
public
static
function
generateShortCode
():
string
{
$code_length
=
env
(
'SIGNUP_CODE_LENGTH'
,
self
::
SHORTCODE_LENGTH
);
return
\App\Utils
::
randStr
(
$code_length
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Nov 3, 2:24 PM (16 h, 59 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
361049
Default Alt Text
SignupCode.php (1 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment