'integer', 'product_id' => 'integer', 'supplier_id' => 'integer', 'price' => 'decimal:2', 'quantity' => 'decimal:2', 'weight' => 'decimal:3', 'amount' => 'decimal:2', 'sort' => 'integer', 'is_sent' => 'integer', 'sent_at' => 'datetime', 'supplier_confirmed_at' => 'datetime', ]; /** * 所属采购单 */ public function purchase(): BelongsTo { return $this->belongsTo(PurchaseOrderModel::class, 'purchase_id', 'id'); } /** * 采购商品 */ public function product(): BelongsTo { return $this->belongsTo(ProductModel::class, 'product_id', 'id'); } /** * 供货供应商 */ public function supplier(): BelongsTo { return $this->belongsTo(SupplierModel::class, 'supplier_id', 'id'); } /** * 金额分摊记录(按订货比例摊到门店/单品) */ public function allocations(): HasMany { return $this->hasMany(PurchaseAllocationModel::class, 'purchase_item_id', 'id'); } }