<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class WaterChangeLog extends Model
{
    protected $fillable = [
        'farm_id', 'pond_id', 'cycle_id', 'change_date', 'change_type',
        'percentage_changed', 'volume_changed_litres', 'reason', 'notes', 'logged_by',
    ];

    protected function casts(): array
    {
        return [
            'change_date' => 'date',
            'percentage_changed' => 'decimal:1',
            'volume_changed_litres' => 'decimal:2',
        ];
    }

    public function pond(): BelongsTo
    {
        return $this->belongsTo(Pond::class);
    }

    public function cycle(): BelongsTo
    {
        return $this->belongsTo(ProductionCycle::class, 'cycle_id');
    }

    public function logger(): BelongsTo
    {
        return $this->belongsTo(User::class, 'logged_by');
    }
}
