<?php

namespace App\Models;

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

class Product extends Model
{
    use HasFactory;

    protected $fillable = [
        'kode_produk',
        'nama',
        'deskripsi',
        'harga',
        'stok',
        'kategori_id',
        'gambar',
        'diskon_persen',
        'is_active',
    ];

    protected $casts = [
        'harga' => 'decimal:2',
        'diskon_persen' => 'decimal:2',
        'is_active' => 'boolean',
    ];

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