<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class Sponsor extends Authenticatable
{
    use HasFactory, Notifiable;

    protected $fillable = [
        'full_name',
        'organization_name',
        'email',
        'mobile',
        'password',
        'country_code',
        'subscription_status',
        'subscription_plan',
        'subscription_start_date',
        'subscription_end_date',
        'payment_status',
        'is_verified',
        'otp_verified_at',
        'profile_image',
        'address',
        'city',
        'nationality',
        'status',
        'last_login_at',
        'api_token',
        'license_file',
    ];

    protected $hidden = [
        'password',
        'api_token',
    ];

    protected $casts = [
        'is_verified' => 'boolean',
        'otp_verified_at' => 'datetime',
        'subscription_start_date' => 'datetime',
        'subscription_end_date' => 'datetime',
        'last_login_at' => 'datetime',
    ];

    public function hasActiveSubscription(): bool
    {
        return $this->subscription_status === 'active' && 
            ($this->subscription_end_date === null || $this->subscription_end_date->isFuture());
    }
}
