<?php

namespace App\Models;

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

class StickerMappingMaster extends Model
{
    use SoftDeletes;

    protected $fillable = [
        'plant_id',
        'item_characteristic_id',

        'sticker_structure1_id',
        'sticker1_machine_id',
        'sticker1_print_ip',
        'sticker_structure2_id',
        'sticker2_machine_id',
        'sticker2_print_ip',
        'sticker_structure3_id',
        'sticker3_machine_id',
        'sticker3_print_ip',
        'sticker_structure4_id',
        'sticker4_machine_id',
        'sticker4_print_ip',
        'sticker_structure5_id',
        'sticker5_machine_id',
        'sticker5_print_ip',
        'sticker_structure7_id',
        'sticker6_machine_id',
        'sticker6_print_ip',
        'sticker_structure7_id',
        'sticker7_machine_id',
        'sticker7_print_ip',
        'sticker_structure8_id',
        'sticker8_machine_id',
        'sticker8_print_ip',

        'created_at',
        'updated_at',
        'created_by',
        'updated_by',
    ];

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

    public function itemCharacteristic()
    {
        return $this->belongsTo(ItemCharacteristic::class);
    }

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

     public function sticker1Structure()
    {
        return $this->belongsTo(StickerStructureDetail::class, 'sticker_structure1_id');
    }

    public function sticker2Structure()
    {
        return $this->belongsTo(StickerStructureDetail::class, 'sticker_structure2_id');
    }

    public function sticker3Structure()
    {
        return $this->belongsTo(StickerStructureDetail::class, 'sticker_structure3_id');
    }

    public function sticker4Structure()
    {
        return $this->belongsTo(StickerStructureDetail::class, 'sticker_structure4_id');
    }

    public function sticker5Structure()
    {
        return $this->belongsTo(StickerStructureDetail::class, 'sticker_structure5_id');
    }

    public function sticker6Structure()
    {
        return $this->belongsTo(StickerStructureDetail::class, 'sticker_structure6_id');
    }

    public function sticker7Structure()
    {
        return $this->belongsTo(StickerStructureDetail::class, 'sticker_structure7_id');
    }

    public function sticker8Structure()
    {
        return $this->belongsTo(StickerStructureDetail::class, 'sticker_structure8_id');
    }

    // Machine relationships (per sticker)
    public function sticker1Machine()
    {
        return $this->belongsTo(Machine::class, 'sticker1_machine_id');
    }

    public function sticker2Machine()
    {
        return $this->belongsTo(Machine::class, 'sticker2_machine_id');
    }

    public function sticker3Machine()
    {
        return $this->belongsTo(Machine::class, 'sticker3_machine_id');
    }

    public function sticker4Machine()
    {
        return $this->belongsTo(Machine::class, 'sticker4_machine_id');
    }

    public function sticker5Machine()
    {
        return $this->belongsTo(Machine::class, 'sticker5_machine_id');
    }

    public function sticker6Machine()
    {
        return $this->belongsTo(Machine::class, 'sticker6_machine_id');
    }

    public function sticker7Machine()
    {
        return $this->belongsTo(Machine::class, 'sticker7_machine_id');
    }

    public function sticker8Machine()
    {
        return $this->belongsTo(Machine::class, 'sticker8_machine_id');
    }
}
