<?php

namespace App\Models;

use App\Enums\SubscriptionPlan;
use App\Enums\SubscriptionStatus;
use Database\Factories\SubscriptionFactory;
use Illuminate\Database\Eloquent\Attributes\Fillable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;

/**
 * @property int $id
 * @property string $full_name
 * @property string $phone
 * @property string $email
 * @property string|null $whatsapp
 * @property string $address
 * @property string $city
 * @property string $pincode
 * @property string|null $landmark
 * @property SubscriptionPlan $plan
 * @property string $plan_price
 * @property Carbon $start_date
 * @property string|null $special_instructions
 * @property bool $terms_agreed
 * @property Carbon|null $terms_agreed_at
 * @property bool $promo_emails
 * @property string|null $ip_address
 * @property string|null $user_agent
 * @property string $order_id
 * @property SubscriptionStatus $order_status
 * @property Carbon|null $created_at
 * @property Carbon|null $updated_at
 */
#[Fillable([
    'full_name', 'phone', 'email', 'whatsapp', 'address', 'city', 'pincode', 'landmark',
    'plan', 'plan_price', 'start_date', 'special_instructions', 'terms_agreed', 'terms_agreed_at',
    'promo_emails', 'ip_address', 'user_agent', 'order_id', 'order_status',
])]
class Subscription extends Model
{
    /** @use HasFactory<SubscriptionFactory> */
    use HasFactory;

    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'subscriptions';

    /**
     * Get the attributes that should be cast.
     *
     * @return array<string, string>
     */
    protected function casts(): array
    {
        return [
            'start_date' => 'date',
            'terms_agreed_at' => 'datetime',
            'terms_agreed' => 'boolean',
            'promo_emails' => 'boolean',
            'plan_price' => 'decimal:2',
            'plan' => SubscriptionPlan::class,
            'order_status' => SubscriptionStatus::class,
        ];
    }
}
