<?php

namespace App\Models;

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

class Makanan extends Model
{
    use HasFactory;
    protected $table = 'makanans';

    protected $fillable = [
        'nama',
        'kategori_id',
        'jenis_id',
        'lemak',
        'natrium',
        'energi',
        'karbohidrat'
    ];

    protected $guarded = [];

    public $timestamps = true;

    public function kategori()
    {
        return $this->belongsTo(Kategori::class, 'kategori_id');
    }

    public function jenis()
    {
        return $this->belongsTo(JenisMakanan::class, 'jenis_id');
    }

    public function skor()
    {
        return $this->hasMany(SkorMakanan::class);
    }

    public function rekomendasi()
    {
        return $this->hasMany(Rekomendasi::class);
    }
}
