<?php

namespace App\Models;

use Database\Factories\PhoneVerificationFactory;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasOne;

class PhoneVerification extends Model
{
    /** @use HasFactory<PhoneVerificationFactory> */
    use HasFactory;

    protected $fillable = ['phone', 'otp', 'expires_at', 'verified'];

    protected function casts(): array
    {
        return [
            'expires_at' => 'datetime',
            'verified' => 'boolean',
        ];
    }

    public function coupon(): HasOne
    {
        return $this->hasOne(Coupon::class, 'phone', 'phone');
    }
}
