<?php

namespace App\Models;

use App\Traits\Blameable;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class MemberPolicy extends Model
{
    use HasFactory, SoftDeletes, Blameable;

    protected $fillable = [
        'policy_id',
        'member_id',
        'status',
        'start',
        'end',
        'created_by',
        'updated_by',
        'deleted_by',
    ];

    public function corporatePolicy()
    {
        return $this->belongsTo(CorporatePolicy::class, 'policy_id', 'code');
    }

    public function member()
    {
        return $this->belongsTo(Member::class, 'member_id', 'member_id');
    }

    // public function setStartAttribute($value)
    // {
    //     $this->attributes['start'] = $value ? strtotime($value) : null;
    // }

    // public function setEndAttribute($value)
    // {
    //     $this->attributes['end'] = $value ? strtotime($value) : null;
    // }
}
