<?php

namespace App\Models;

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

class Produk extends Model
{
    use HasFactory;

    protected $table = 'produks';

    protected $fillable = [
        'petani_id',
        'nama_produk',
        'harga',
        'stok',
        'deskripsi',
        'foto_produk'
    ];

    public function petani()
    {
        return $this->belongsTo(Petani::class, 'petani_id');
    }

    public function detailTransaksis()
    {
        return $this->hasMany(DetailTransaksi::class, 'produk_id');
    }

    public function images()
    {
        return $this->hasMany(ProdukImage::class, 'produk_id');
    }

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