<?php

namespace App\Models\Distribusi;

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

class Distribution extends Model
{
    use HasFactory, SoftDeletes;

    protected $table = 'distributions';

    // Karena id adalah BIGINT auto-increment, default Laravel sudah benar (incrementing = true)
    protected $fillable = [
        'farmer_id', 'farmer_name', 'offtaker_id', 'offtaker_name',
        'commodity_name', 'quantity_kg', 'farmer_grade', 'offtaker_grade',
        'grade_difference_reason', 'price_per_kg', 'total_value',
        'distribution_date', 'received_date', 'notes', 'status', 
        'sync_status', 'created_date', 'updated_date'
    ];

    protected $casts = [
        'quantity_kg' => 'float',
        'price_per_kg' => 'float',
        'total_value' => 'float',
        'created_date' => 'datetime',
        'updated_date' => 'datetime',
    ];
}