<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class UserOtp extends Model
{
    use HasFactory;

    protected $table = 'user_otps';

    protected $fillable = [
        'otp',
        'expired_at',
        'user_id',
        'user_identity',
    ];

    public function user()
    {
        return $this->hasOne(User::class, 'id', 'user_id');
    }

    public function format() : array{

        return [
            'id' => $this->id,
            'otp' => $this->otp,
            'expired_at' => $this->expired_at,
            'user_id' => $this->user_id,
            'user' => $this->user,
        ];
    }

}
