<?php

namespace App\Models;

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

class Producto extends Model
{
    use HasFactory;

    protected $table = 'productos';

    public function marco()
    {
        return $this->hasMany(ProductosMarco::class, 'product_id');
    }

    public function Mpd()
    {
        //return $this->hasMany(ProductosMpd::class, 'product_id')->with('Insumo');
        return $this->hasMany(ProductosMpd::class, 'product_id')->with('Trazabilidad');
    }

    public function Trazabilidad()
    {
        return $this->hasMany(ProductosTrazabilidad::class, 'product_id')->with('Trazabilidad');
    }

    public function Mod()
    {
        return $this->hasMany(ProductosMod::class, 'product_id')->with('Mod');
    }

    public function desplegados()
    {
        return $this->hasMany(ProductosDesplegado::class, 'product_id')->with('Desplegados');
    }

    public function Sectores()
    {
        return $this->hasMany(ProductoSector::class, 'product_id')->with('Sector');
    }

    public function sectores_primera_etapa()
    {
        return $this->hasMany(ProductoSector::class, 'product_id')->with('Sector')->where('stage', 1);
    }
}
