|
|
@@ -15,21 +15,22 @@ class DropCommodityBarcodeColumnToBarcodeTable extends Migration
|
|
|
*/
|
|
|
public function up()
|
|
|
{
|
|
|
- DB::insert('INSERT commodity_barcodes (code,commodity_id) SELECT barcode, id FROM commodities');
|
|
|
- $this->delRepeated();
|
|
|
+// \App\Commodity::query()->count();
|
|
|
+// DB::insert('INSERT commodity_barcodes (code,commodity_id) SELECT barcode, id FROM commodities');
|
|
|
+// $this->delRepeated();
|
|
|
Schema::table('commodities', function (Blueprint $table) {
|
|
|
$table->dropColumn('barcode');
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private function delRepeated(){
|
|
|
- $codes=CommodityBarcode::groupBy('code','commodity_id')->havingRaw('count(*) > ?', [1])->get();
|
|
|
- $codes->each(function(CommodityBarcode $code){
|
|
|
- $delCodes=CommodityBarcode::where('code',$code['code'])->where('commodity_id',$code['commodity_id'])->where('id','!=',$code['id'])->get();
|
|
|
- $delCodes->each(function(CommodityBarcode $delcode){
|
|
|
- $delcode->delete();
|
|
|
- });
|
|
|
- });
|
|
|
- }
|
|
|
+// private function delRepeated(){
|
|
|
+// $codes=CommodityBarcode::groupBy('code','commodity_id')->havingRaw('count(*) > ?', [1])->get();
|
|
|
+// $codes->each(function(CommodityBarcode $code){
|
|
|
+// $delCodes=CommodityBarcode::where('code',$code['code'])->where('commodity_id',$code['commodity_id'])->where('id','!=',$code['id'])->get();
|
|
|
+// $delCodes->each(function(CommodityBarcode $delcode){
|
|
|
+// $delcode->delete();
|
|
|
+// });
|
|
|
+// });
|
|
|
+// }
|
|
|
|
|
|
}
|