<?php

namespace App\Models;

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

class Kematian extends Model
{
    use HasFactory;

    protected $table = 'kematian';

    protected $fillable = [
        'penduduk_id',
        'tanggal_kematian',
        'penyebab',
    ];

    protected $casts = [
        'tanggal_kematian' => 'date',
    ];

    /**
     * Get the penduduk that owns the Kematian
     *
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     */
    public function penduduk(): BelongsTo
    {
        return $this->belongsTo(Penduduk::class);
    }
}