<?php

namespace App\Models;

# use Illuminate\Database\Eloquent\Model;

class Shipment extends Model
{
    protected $table = 'shipment';

    public function client()
    {
        return $this->hasOne(Client::class, 'id', 'client_id');
    }

    public function supplyOrders() {
        return $this->hasMany(SupplyOrder::class, 'shipment_id', 'id');
    }

    public function labelFile() {
        return $this->hasOne(SystemFile::class, 'id', 'label_system_file_id');
    }

    public function createdSession()
    {
        return $this->hasOne(AppSession::class, 'id', 'created_by_session_id');
    }

    public function packs() {
        return $this->hasMany(Pack::class, 'shipment_id', 'id');
    }

    public function supplyOrdersNotInPack() {
        return $this->supplyOrders()->whereNull('pack_id');
    }
}
