Files
portal/app/app/Models/UserRecoveryCode.php
T

53 lines
1.3 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
namespace App\Models;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Carbon;
/**
* Резервные коды 2FA пользователя (по schema v8.7 §10).
*
* 8 одноразовых кодов на user, хранятся как bcrypt-хеши.
* При использовании ставится `used_at = NOW()`.
*
* @property int $id
* @property int $user_id
* @property string $code_hash
* @property Carbon|null $used_at
* @property Carbon|null $created_at
*
* @mixin IdeHelperUserRecoveryCode
*/
class UserRecoveryCode extends Model
{
/**
* Schema-таблица не имеет updated_at — отключаем только его.
* created_at управляется руками или через DEFAULT NOW().
*/
public const UPDATED_AT = null;
protected $fillable = [
'user_id',
'code_hash',
'used_at',
];
protected function casts(): array
{
return [
'used_at' => 'datetime',
'created_at' => 'datetime',
];
}
/** @return BelongsTo<User, $this> */
public function user(): BelongsTo
{
return $this->belongsTo(User::class);
}
}