<?php

namespace App\Repositories\Core\Auth;

use App\Models\Core\Auth\PasswordSecurity;
use Carbon\Carbon;

class PasswordSecurities
{
    public static function create($user_id, $delay = 90)
    {
        return PasswordSecurity::create([
            'user_id' => $user_id,
            'password_expiry_days' => $delay,
            'password_updated_at' => Carbon::now(),
        ]);
    }

    public static function getUserName($id)
    {
        return self::getUser($id)->username;
    }

    public static function getUser($id)
    {
        return PasswordSecurity::with('user')->find($id)->user;
    }
}
