<?php

namespace App\Models;

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

class SubKriteria extends Model
{
    use HasFactory;

    protected $table = 'sub_kriterias';
    protected $primaryKey = 'id'; 

    protected $fillable = ['kriteria_id', 'nama_subkriteria', 'nilai'];
    protected $casts = ['nilai' => 'integer'];

    public function kriteria()
    {
        return $this->belongsTo(Kriteria::class, 'kriteria_id');
    }    

    public function penilaian()
    {
        return $this->hasMany(Penilaian::class, 'sub_kriteria_id');
    }
}
