<?php

namespace App\Models;

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

class Member extends Model
{
    use HasFactory;

    protected $fillable = [
        'surname',
        'first_name',
        'dob',
        'gender',
        'address',
        'mobile',
        'email',
        'disability',
        'disability_details',
        'emergency_contact_name',
        'emergency_contact_relationship',
        'emergency_contact_mobile',
        'membership_type',
        'package_type',
        'admission_fee',
        'application_number',
        'fingerprint_id',    // ✅ must match approve function
        'status',
        'approval_date',
        'expiry_date',
        'next_payment_date',
        'profile_pic',
        'referral_source',
        'signature',
        'staff_signature',
        'induction_date',
        'qr_code_url',
    ];

    protected $casts = [
    'approval_date' => 'datetime',
    'expiry_date' => 'datetime',
    'next_payment_date' => 'datetime',
    'dob' => 'date',
];


    public function payments()
    {
        return $this->hasMany(Payment::class);
    }

    public function rejections()
    {
        return $this->hasMany(Rejection::class);
    }

    public function fullName()
    {
        return trim("{$this->first_name} {$this->surname}");
    }
}
