$goods_id,'depot_id'=>$depot_id])->count(); if($check_goods) return true; $int_data=[ 'depot_id' => $depot_id, 'goods_id' => $goods_id, 'sort' => 0, 'create_at' => date("Y-m-d H:i:s") ]; self::create($int_data); $goods_item = StoreGoodsItem::where('goods_id',$goods_id)->field("goods_id,id as spec_id,goods_spec")->select()->toArray(); array_walk($goods_item,function (&$v,$k)use($depot_id,$goods_id){ $v['depot_id'] = $depot_id; Data::save('DepotGoodsItem',$v,'depot_id',['depot_id'=>$depot_id,'goods_id'=>$goods_id,'spec_id'=>$v['spec_id']]); }); } public function itemList() { return $this->hasMany('DepotGoodsItem','goods_id','id'); } }