<?php

namespace App\Models;

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

class BatchSplitEvent extends Model
{
    use HasFactory;

    protected $fillable = [
        'user_id',
        'batch_split_session_id',
        'source_batch_id',
        'destination_batch_id',
        'grading_label',
        'date',
        'fish_count_theoretical',
        'fish_count_counted',
        'fish_moved',
        'fish_missing',
        'avg_weight_moved_g',
        'biomass_moved_kg',
        'notes',
    ];

    protected $casts = [
        'date' => 'date',
    ];

    public function sourceBatch(): BelongsTo
    {
        return $this->belongsTo(Batch::class, 'source_batch_id');
    }

    public function session(): BelongsTo
    {
        return $this->belongsTo(BatchSplitSession::class, 'batch_split_session_id');
    }

    public function destinationBatch(): BelongsTo
    {
        return $this->belongsTo(Batch::class, 'destination_batch_id');
    }
}
