<?php

namespace App\Models;

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

class Komponen extends Model
{
    use HasFactory;

    protected $fillable = ['nama'];

    public function makananKomponenWaktu()
    {
        return $this->hasMany(MakananKomponenWaktu::class);
    }

    public function makanans()
    {
        return $this->belongsToMany(Makanan::class, 'makanan_komponen_waktu')
                    ->withPivot('waktu_makan_id')
                    ->withTimestamps();
    }
}
