<?php

namespace App;

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

use App\Traits\ModelLogChanging;

class OrderCommodityAssign extends Model
{
    use ModelLogChanging;

    use ModelTimeFormat;
    protected $fillable = [
        "order_id",         //外键订单
        "commodity_id",     //外键商品
        "amount",           //数量  default 0
        "produced_at",      //生产日期
        "valid_at",         //失效日期
        "batch_number",     //批次号
        "location",         //库位
        "region",           //库区
        "user_id",          //操作人
    ];

    public function order()
    {   //订单
        return $this->hasOne(Order::class,"id","order_id");
    }
    public function commodity()
    {   //商品
        return $this->hasOne(Commodity::class,"id","commodity_id");
    }
    public function user()
    {   //用户
        return $this->hasOne(User::class,"id","user_id");
    }
}
