Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2529647
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/app/SignupCode.php b/src/app/SignupCode.php
index 73ecd7af..0e5e1559 100644
--- a/src/app/SignupCode.php
+++ b/src/app/SignupCode.php
@@ -1,106 +1,106 @@
<?php
namespace App;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
/**
* The eloquent definition of a SignupCode.
*
* @property string $code The full code identifier
* @property \Carbon\Carbon $created_at The creation timestamp
* @property \Carbon\Carbon $deleted_at The deletion timestamp
- * @property string $domain_part Email domain
- * @property string $email Email address
+ * @property ?string $domain_part Email domain
+ * @property ?string $email Email address
* @property \Carbon\Carbon $expires_at The code expiration timestamp
- * @property string $first_name Firstname
+ * @property ?string $first_name Firstname
* @property string $ip_address IP address the request came from
- * @property string $last_name Lastname
- * @property string $local_part Email local part
- * @property string $plan Plan title
+ * @property ?string $last_name Lastname
+ * @property ?string $local_part Email local part
+ * @property ?string $plan Plan title
* @property string $short_code Short validation code
* @property \Carbon\Carbon $updated_at The update timestamp
- * @property string $voucher Voucher discount code
+ * @property ?string $voucher Voucher discount code
*/
class SignupCode extends Model
{
use SoftDeletes;
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';
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'code',
'email',
'expires_at',
'first_name',
'last_name',
'plan',
'short_code',
'voucher'
];
protected $casts = ['headers' => '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-diff
Expires
Mon, Feb 2, 7:44 PM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
426948
Default Alt Text
(3 KB)
Attached To
Mode
R2 kolab
Attached
Detach File
Event Timeline
Log In to Comment