<?php

namespace App\Models;

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

class WarehouseTransfer extends Model
{
    protected $table = 'warehouse_transfers';
    
    protected $fillable = [
        'document_number',
        'transfer_date',
        'from_warehouse_id',
        'to_warehouse_id',
        'reference_number',
        'notes',
        'status'
    ];

    public function fromWarehouse(): BelongsTo
    {
        return $this->belongsTo(Warehouse::class, 'from_warehouse_id');
    }

    public function toWarehouse(): BelongsTo
    {
        return $this->belongsTo(Warehouse::class, 'to_warehouse_id');
    }

    public function lines(): HasMany
    {
        return $this->hasMany(WarehouseTransferLine::class, 'transfer_id');
    }
}