84 lines
1.8 KiB
PHP
84 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use App\Support\WowData;
|
|
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
|
use Illuminate\Support\Carbon;
|
|
|
|
class GameAccountUser implements AuthenticatableContract
|
|
{
|
|
public function __construct(
|
|
public readonly int $id,
|
|
public readonly string $username,
|
|
public readonly string $email,
|
|
public readonly string $regMail,
|
|
public readonly int $gmLevel,
|
|
public readonly bool $locked,
|
|
public readonly ?string $lastLoginAt,
|
|
public readonly ?string $joinedAt,
|
|
public readonly string $saltHex,
|
|
public readonly string $verifierHex,
|
|
) {
|
|
}
|
|
|
|
public function getAuthIdentifierName(): string
|
|
{
|
|
return 'id';
|
|
}
|
|
|
|
public function getAuthIdentifier(): int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getAuthPasswordName(): string
|
|
{
|
|
return 'verifier';
|
|
}
|
|
|
|
public function getAuthPassword(): string
|
|
{
|
|
return $this->verifierHex;
|
|
}
|
|
|
|
public function getRememberToken(): string
|
|
{
|
|
return '';
|
|
}
|
|
|
|
public function setRememberToken($value): void
|
|
{
|
|
}
|
|
|
|
public function getRememberTokenName(): string
|
|
{
|
|
return 'remember_token';
|
|
}
|
|
|
|
public function accessLabel(): string
|
|
{
|
|
return WowData::securityLevelName($this->gmLevel);
|
|
}
|
|
|
|
public function canAccessAdminPanel(): bool
|
|
{
|
|
return $this->gmLevel >= config('moonwell.portal.admin_min_gm_level');
|
|
}
|
|
|
|
public function joinedAtLabel(): string
|
|
{
|
|
return $this->formatDate($this->joinedAt);
|
|
}
|
|
|
|
public function lastLoginLabel(): string
|
|
{
|
|
return $this->formatDate($this->lastLoginAt);
|
|
}
|
|
|
|
private function formatDate(?string $value): string
|
|
{
|
|
return $value ? Carbon::parse($value)->format('d.m.Y H:i') : '—';
|
|
}
|
|
}
|