id)->column('sn'))->findOrEmpty(); $effective = EffectiveCategory::with('effectiveRule')->where('goods_category_id',$orderGoods->goods_category_id)->findOrEmpty(); if(!$effective->isEmpty()){ OrderEffectiveLog::create([ 'effective_id' => $effective->effectiveRule->id, 'sn' => $orderGoods['sn'], 'user_id' => $work['user_id'], 'work_id' => $work->id, 'goods_id' => $orderGoods->goods_id, 'effective_unit' => $effective->effectiveRule->effective_unit, 'effective_num' => $effective->effectiveRule->effective_num, 'remark' => $effective->effectiveRule->remark, 'end_effective_time' => EffectiveRules::formatEndEffectiveTime(time() ,$effective->effectiveRule->effective_num,$effective->effectiveRule->effective_unit), ]); } } }