Changeset View
Changeset View
Standalone View
Standalone View
src/app/SignupCode.php
<?php | <?php | ||||
namespace App; | namespace App; | ||||
use Carbon\Carbon; | use Carbon\Carbon; | ||||
use Illuminate\Database\Eloquent\Model; | use Illuminate\Database\Eloquent\Model; | ||||
/** | /** | ||||
* The eloquent definition of a SignupCode. | * The eloquent definition of a SignupCode. | ||||
* | * | ||||
* @property datetime $expires_at | * @property string $code | ||||
* @property array $data | |||||
* @property \Carbon\Carbon $expires_at | |||||
* @property string $short_code | |||||
*/ | */ | ||||
class SignupCode extends Model | class SignupCode extends Model | ||||
{ | { | ||||
// Note: Removed '0', 'O', '1', 'I' as problematic with some fonts | // Note: Removed '0', 'O', '1', 'I' as problematic with some fonts | ||||
public const SHORTCODE_CHARS = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ'; | public const SHORTCODE_CHARS = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ'; | ||||
public const SHORTCODE_LENGTH = 5; | public const SHORTCODE_LENGTH = 5; | ||||
public const CODE_LENGTH = 32; | public const CODE_LENGTH = 32; | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | class SignupCode extends Model | ||||
/** | /** | ||||
* Check if code is expired. | * Check if code is expired. | ||||
* | * | ||||
* @return bool True if code is expired, False otherwise | * @return bool True if code is expired, False otherwise | ||||
*/ | */ | ||||
public function isExpired() | public function isExpired() | ||||
{ | { | ||||
// @phpstan-ignore-next-line | |||||
return $this->expires_at ? Carbon::now()->gte($this->expires_at) : false; | return $this->expires_at ? Carbon::now()->gte($this->expires_at) : false; | ||||
} | } | ||||
/** | /** | ||||
* Generate a short code (for human). | * Generate a short code (for human). | ||||
* | * | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
Show All 15 Lines |