<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

use Illuminate\Database\Eloquent\SoftDeletes;
use App\Models\Product\Product;
use App\Models\Supplier\Supplier;
use App\Models\User;

class InventoryMovement extends Model
{
    use SoftDeletes;

    protected $table = 'movimiento_inventario';

    protected $fillable = [
        'codigo_movimiento',
        'tipo',
        'fecha',
        'idProveedor',
        'guia_remision',
        'firma_entrega',
        'firma_recepcion',
        'recepcion_evidencia',
        'observacion',
        'recepcion_observacion',
        'recepcionado_por',
        'recepcionado_at',
        'user_id',
        'state'
    ];

    public function details()
    {
        return $this->hasMany(InventoryMovementDetail::class, 'idMovimiento');
    }

    public function supplier()
    {
        return $this->belongsTo(Supplier::class, 'idProveedor', 'idProveedor');
    }

    public function user()
    {
        return $this->belongsTo(User::class, 'user_id');
    }

    public function receiver()
    {
        return $this->belongsTo(User::class, 'recepcionado_por');
    }
}
