<?php

namespace App\Models;

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

class DataDBD extends Model
{
    protected $table = 'data_dbd';

    protected $fillable = ['id_kecamatan', 'bulan', 'tahun', 'jumlah_kasus'];

    public function kecamatan()
    {
        return $this->belongsTo(Kecamatan::class, 'id_kecamatan', 'id');
    }
    
    public static function getDataByYear($year)
    {
        return static::where('tahun', $year)->get();
    }

}

