<?php

namespace App\Models;

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

class Line extends Model
{
    use SoftDeletes;

    protected $fillable = [
        'plant_id',
        'block_id',
        'name',
        'type',
        'line_capacity',
        'group_work_center',
        'no_of_operation',
        'work_group1_id',
        'work_group2_id',
        'work_group3_id',
        'work_group4_id',
        'work_group5_id',
        'work_group6_id',
        'work_group7_id',
        'work_group8_id',
        'work_group9_id',
        'work_group10_id',
    ];

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

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

    public function qualityValidations()
    {
        return $this->hasMany(QualityValidation::class);
    }

    public function testingPanelReadings()
    {
        return $this->hasMany(TestingPanelReading::class);
    }

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

    public function processOrders()
    {
        return $this->hasMany(ProcessOrder::class);
    }

    public function machines()
    {
        return $this->hasMany(Machine::class);
    }

    public function productCharacteristicsMasters()
    {
        return $this->hasMany(ProductCharacteristicsMaster::class);
    }

    public function characteristicValues()
    {
        return $this->hasMany(CharacteristicValue::class);
    }

    public function productionCharacteristics()
    {
        return $this->hasMany(ProductionCharacteristic::class);
    }

    public function workGroup1()
    {
        return $this->belongsTo(WorkGroupMaster::class, 'work_group1_id', 'id');
    }

    public function workGroup2()
    {
        return $this->belongsTo(WorkGroupMaster::class, 'work_group2_id', 'id');
    }

    public function workGroup3()
    {
        return $this->belongsTo(WorkGroupMaster::class, 'work_group3_id', 'id');
    }

    public function workGroup4()
    {
        return $this->belongsTo(WorkGroupMaster::class, 'work_group4_id', 'id');
    }

    public function workGroup5()
    {
        return $this->belongsTo(WorkGroupMaster::class, 'work_group5_id', 'id');
    }

    public function workGroup6()
    {
        return $this->belongsTo(WorkGroupMaster::class, 'work_group6_id', 'id');
    }

    public function workGroup7()
    {
        return $this->belongsTo(WorkGroupMaster::class, 'work_group7_id', 'id');
    }

    public function workGroup8()
    {
        return $this->belongsTo(WorkGroupMaster::class, 'work_group8_id', 'id');
    }

    public function workGroup9()
    {
        return $this->belongsTo(WorkGroupMaster::class, 'work_group9_id', 'id');
    }

    public function workGroup10()
    {
        return $this->belongsTo(WorkGroupMaster::class, 'work_group10_id', 'id');
    }

    public function workGroupMasters1()
    {
        return $this->hasMany(WorkGroupMaster::class, 'work_group1_id', 'id');
    }

    public function workGroupMasters2()
    {
        return $this->hasMany(WorkGroupMaster::class, 'work_group2_id', 'id');
    }

    public function workGroupMasters3()
    {
        return $this->hasMany(WorkGroupMaster::class, 'work_group3_id', 'id');
    }

    public function workGroupMasters4()
    {
        return $this->hasMany(WorkGroupMaster::class, 'work_group4_id', 'id');
    }

    public function workGroupMasters5()
    {
        return $this->hasMany(WorkGroupMaster::class, 'work_group5_id', 'id');
    }

    public function workGroupMasters6()
    {
        return $this->hasMany(WorkGroupMaster::class, 'work_group6_id', 'id');
    }

    public function workGroupMasters7()
    {
        return $this->hasMany(WorkGroupMaster::class, 'work_group7_id', 'id');
    }

    public function workGroupMasters8()
    {
        return $this->hasMany(WorkGroupMaster::class, 'work_group8_id', 'id');
    }

    public function workGroupMasters9()
    {
        return $this->hasMany(WorkGroupMaster::class, 'work_group9 _id', 'id');
    }

    public function workGroupMasters10()
    {
        return $this->hasMany(WorkGroupMaster::class, 'work_group10_id', 'id');
    }

    // public function rejectReasons()
    // {
    //     return $this->hasMany(RejectReason::class, 'line_id', 'id');
    // }

    public function panelBoxValidations()
    {
        return $this->hasMany(PanelBoxValidation::class);
    }
}
