<?php

namespace App\Domains\Auth\Models;

use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

#[Fillable([
    'user_id',
    'email_fingerprint',
    'tenant_codigo',
    'outcome',
    'ip_address',
    'user_agent',
])]
class LoginAttempt extends Model
{
    public const OUTCOME_SUCCESS = 'success';

    public const OUTCOME_INVALID_CREDENTIALS = 'invalid_credentials';

    public const OUTCOME_ACCOUNT_LOCKED = 'account_locked';

    public const UPDATED_AT = null;

    /** @return BelongsTo<User, $this> */
    public function user(): BelongsTo
    {
        return $this->belongsTo(User::class);
    }

    protected function casts(): array
    {
        return [
            'user_id' => 'integer',
            'created_at' => 'datetime',
        ];
    }
}
