<?php

namespace App\Models;

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

class DispatchGuideDetail extends Model
{
    use HasFactory;

    protected $table = "tbl_dispatch_guide_details";

    protected $fillable = [
        'iddispatch_guide',
        'idticket',
        'idproduct',
        'quantity',
        'idcompany',
        'status'
    ];

    protected $hidden = [
        'created_at',
        'updated_at'
    ];

    # Relaciones
    public function dispatchGuide(): BelongsTo
    {
        return $this->belongsTo(DispatchGuide::class, 'iddispatch_guide', 'id');
    }
    
    public function ticket(): BelongsTo
    {
        return $this->belongsTo(Ticket::class, 'idticket', 'id');
    }
    
    public function product(): BelongsTo
    {
        return $this->belongsTo(Product::class, 'idproduct', 'id');
    }
    
    public function company(): BelongsTo
    {
        return $this->belongsTo(Company::class, 'idcompany', 'id');
    }
    
}
