<?php

namespace App\Models;

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

class PumpTestingMaster extends Model
{
    use SoftDeletes;

    protected $fillable = [
        'plant_id',
        'item_id',
        'head',
        'head_type',
        'discharge',
        'discharge_type',
        'motor_efficiency',
        'pump_efficiency',
        'speed',
        'frequency',
        'i_max',
        'p_input',
        'delivery_size',
        'no_of_stages',
        'size',
        'maximum_head',
        'motor_type',
        'motor_code',
        'kw_hp',
        'connection_type',
        'voltage',
        'phase',
        'oh_minimum',
        'oh_maximum',
        'current_minimum',
        'current_maximum',
        'class_of_insulation',
        'testing_code',
        'created_at',
        'updated_at',
        'created_by',
        'updated_by',
    ];

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

    public function item(): BelongsTo
    {
        return $this->belongsTo(Item::class, 'item_id', 'id');
    }

    public function pumpTestingEntries()
    {
        return $this->hasMany(PumpTestingEntry::class, 'pump_testing_master_id', 'id');
    }

    public function pumpTestingResults()
    {
        return $this->hasMany(PumpTestingResult::class, 'pump_testing_master_id', 'id');
    }
}
