<?php

namespace App;

use App\Traits\ModelTimeFormat;
use Illuminate\Database\Eloquent\Model;

use App\Traits\ModelLogChanging;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;

class OrderPackageCommodities extends Model
{
    use ModelLogChanging;

    //
    use ModelTimeFormat;

    /*
     * amount => OracleActAllocationDetails->qty_each
     */
    protected $fillable = [
        'order_package_id','commodity_id','amount'
    ];


    public function package(): BelongsTo
    {
        return $this->belongsTo(OrderPackage::class,'order_package_id','id');
    }

    public function commodity(): BelongsTo
    {
        return $this->belongsTo(Commodity::class,'commodity_id','id');
    }

    public function orderTracking(): BelongsTo
    {
        return $this->belongsTo(OrderTracking::class,'id','order_package_commodity_id');
    }

    public function serialNumbers(): HasMany
    {
        return $this->hasMany(OrderPackageCommoditySerialNumber::class,'order_package_commodity_id','id');
    }
}
