<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class PatientPlan extends Model
{
    protected $table = 'patient_plans';

    protected $fillable = [
        'name','name_ar','description',
        'price_monthly','price_yearly',
        'unlimited_appointments','appointments_per_month',
        'priority_queue','medical_records_access',
        'prescription_download','lab_results_upload',
        'online_consultation','family_members','family_members_count',
        'show_ads','features','is_active','sort_order',
    ];

    protected $casts = [
        'features'                => 'array',
        'unlimited_appointments'  => 'boolean',
        'priority_queue'          => 'boolean',
        'medical_records_access'  => 'boolean',
        'prescription_download'   => 'boolean',
        'lab_results_upload'      => 'boolean',
        'online_consultation'     => 'boolean',
        'family_members'          => 'boolean',
        'show_ads'                => 'boolean',
        'is_active'               => 'boolean',
        'price_monthly'           => 'decimal:2',
        'price_yearly'            => 'decimal:2',
    ];

    public function subscriptions()
    {
        return $this->hasMany(PatientSubscription::class, 'plan_id');
    }

    public function isFree(): bool
    {
        return $this->price_monthly == 0;
    }
}
