<?php

namespace App\Models\Member;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Carbon;

class MemInfo extends Model
{
    protected $table = 'mem_info';
    protected $primaryKey = 'mem_no';
    protected $keyType = 'int';
    public $incrementing = true;
    public $timestamps = false;

    protected $fillable = [
        'stat_1','stat_2','stat_3','stat_4','stat_5',
        'name','name_first','name_mid','name_last',
        'birth','gender','native',
        'cell_corp','cell_phone','email','pv_sns',
        'bank_code','bank_name','bank_act_num','bank_vact_num',
        'rcv_email','rcv_sms','rcv_push',
        'login_fail_cnt',
        'dt_login','dt_reg','dt_mod',
        'dt_rcv_email','dt_rcv_sms','dt_rcv_push',
        'dt_stat_1','dt_stat_2','dt_stat_3','dt_stat_4','dt_stat_5',
        'ip_reg','ci_v','ci','di',
        'country_code','country_name',
        'admin_memo','modify_log',
    ];

    private function safeCarbon(?string $value): ?Carbon
    {
        if (!$value) return null;
        if ($value === '0000-00-00 00:00:00' || $value === '0000-00-00') return null;

        try {
            return Carbon::parse($value);
        } catch (\Throwable $e) {
            return null;
        }
    }
}
