Пример #1
0
 public function fire($job, $data)
 {
     Log::debug('im execute at' . date('d m Y h:i:s'));
     if (isset($data['total'])) {
         $total = $data['total'];
         $fake = \Faker\Factory::create();
         set_time_limit(9000);
         $legalities = Legality::lists('id');
         if (!count($legalities)) {
             throw new Exception('Daftar Legality tidak ada');
         }
         $status = Status::lists('id');
         if (!count($status)) {
             throw new Exception('Status tidak ada');
         }
         $type = Typesuppliersbuyers::lists('id');
         if (!count($type)) {
             throw new Exception('Type Tidak ada');
         }
         $type_products = Producttype::lists('id');
         if (!count($type_products)) {
             throw new Exception('Type Product Tidak ada');
         }
         $uid = $data['uid'];
         $total = 1000;
         for ($i = 0; $i < $total; $i++) {
             $legality_id = $legalities[rand(0, count($legalities) - 1)];
             $status_id = $status[rand(0, count($status) - 1)];
             $type_id = $type[rand(0, count($type) - 1)];
             $typeproduct_id = $type_products[rand(0, count($type_products) - 1)];
             Input::replace(array('name' => $fake->name, 'codepos' => '450' . rand(10, 90), 'npwp' => '0299-292-18002990-' . rand(100, 900), 'fax' => $fake->phoneNumber, 'email' => $fake->companyEmail, 'plafon' => rand(900, 92093) * $fake->randomDigitNotNull(), 'kredit' => rand(1, 365), 'address' => $fake->streetAddress, 'status_id' => 1, 'rt' => rand(1, 15), 'rw' => rand(1, 15), "city_id" => 12, "country_id" => 1, "legality_id" => $legality_id, "phone" => $fake->phoneNumber, "province_id" => 8, "status_id" => $status_id, "tipe_id" => $type_id, "typeprod_id" => $typeproduct_id, 'uuid' => $fake->uuid, 'createby_id' => $uid, 'lastupdateby_id' => $uid, 'created_at' => $fake->dateTimeBetween("-5 years"), 'updated_at' => $fake->dateTimeBetween("-11 month"), 'codeinternal' => $fake->uuid));
             /*==========  Sesuaikan dengan Field di table  ==========*/
             Buyers::create(Input::all());
             $memory = $this->niceUnits(memory_get_usage(true));
             Log::debug("Memory Usage {$memory}", array('context' => 'Send TO Queue' . date('d m Y h:i:s')));
         }
         $job->delete();
     }
 }
Пример #2
0
 /**
  * @param bool $resultsIds
  * @param int  $count
  *
  * @return array|string
  */
 public static function generateMassiveDummy($resultsIds = false, $count = 100)
 {
     /** Buat Data fake Instance */
     $fake = static::getFake()->getSupplier();
     /** Cari Legalitas */
     $listLegalitiesId = Legality::getIdsOrGenerateDummyData(100);
     /** Status */
     $listStatusId = Status::getIdsOrCreate();
     /*Product Type*/
     $typeProductIds = Producttype::getIdsOrCreateDummy(100);
     /*Type Supplier*/
     $typeIdsSupBuy = Typesuppliersbuyers::generateDummyData(true);
     /** Locations */
     $countryId = Locations::getIdsDefaultCountryOrCreate();
     $provinceId = Locations::getIdsDefaultProvinceOrCreate($countryId);
     $cityId = Locations::getIdsDefaultCityOrCreate($provinceId);
     $suppliers = $fake->generateSuppliers($count, $typeIdsSupBuy, $typeProductIds, $listLegalitiesId, $countryId, $provinceId, $cityId, $listStatusId);
     foreach ($suppliers as $sup) {
         $s = static::create($sup);
         $supIds[] = $s->id;
     }
     Log::debug('Supplier Masih Kosong , Sudah diisi ' . count($supIds));
     return $resultsIds ? $supIds : "Generate " . count($supIds) . " records";
 }
Пример #3
0
 /**
  * @param bool $resultsIds
  * @param int $count
  *
  * @return array|string
  */
 public static function generateDummyData($resultsIds = false, $count = 10)
 {
     /** Legalitas */
     $listLegalitiesId = Legality::getIdsOrGenerateDummyData(100);
     /** Status */
     $listStatusId = Status::getIdsOrCreate();
     /*Product Type*/
     $typeProductIds = Producttype::getIdsOrCreateDummy(100);
     /*Type Supplier*/
     $typeIdsSupBuy = Typesuppliersbuyers::generateDummyData(true);
     /** Locations */
     $countryId = Locations::getIdsDefaultCountryOrCreate();
     $provinceId = Locations::getIdsDefaultProvinceOrCreate($countryId);
     $cityId = Locations::getIdsDefaultCityOrCreate($provinceId);
     $records = static::getFake()->getBuyers()->createBuyers($count, $typeIdsSupBuy, $typeProductIds, $listLegalitiesId, $countryId, $provinceId, $cityId, $listStatusId);
     foreach ($records as $record) {
         $newrecord = static::createRecord($record);
         $recordIds[] = $newrecord->id;
     }
     \Log::debug('Supplier Masih Kosong , Sudah diisi ' . count($recordIds));
     return $resultsIds ? $recordIds : "Generate " . count($recordIds) . " records";
 }
Пример #4
0
 public static function generateSampleProducts($count = 10)
 {
     //		Type
     $typeIds = Producttype::getIdsOrCreateDummy();
     //		category
     $categoryIds = Productcategory::getIdsOrCreateSampelData();
     //		unit berat
     $unitIds = Units::getIdsOrCreateSampleUnits();
     //		parent_id
     $parentId = 0;
     $fake = static::getFake();
     //
     //		Buat Product
     $catId = $fake->getFake()->randomElement($categoryIds);
     $typeId = $fake->getFake()->randomElement($typeIds);
     $unitWeightId = $fake->getFake()->randomElement($unitIds);
     $unitWidthId = $fake->getFake()->randomElement($unitIds);
     $supplierIds = Suppliers::getRecordIdsOrCreate();
     $currencyIds = Currencies::getIdsOrCreateSample();
     //		color
     $colorIds = Colors::getIdsOrCreate();
     //  gradeIds
     $gradeIds = Fabricgrade::getIdsOrCreate();
     $productIds = array();
     for ($rec = 0; $rec < $count; $rec++) {
         $product = $fake->getProduct()->product($catId, $typeId, $unitWeightId, $unitWidthId, $parentId, '\\Emayk\\Ics\\Repo\\Productcategory\\Productcategory');
         $record = static::createRecord($product);
         $productId = $record->id;
         $productIds[] = $productId;
         //		Image/ Photo Product
         $imagesIds[] = Images::getIdsOrCreate($productId, '\\Emayk\\Ics\\Repo\\Products\\Products');
         //			Supplier Product
         //		Product Supplier (Product dapat dari Supplier mana ?)
         $supplierId = $fake->getFake()->randomElement($supplierIds);
         $supplierProduct = Productsuppliers::create(array('master_product_id' => $productId, 'master_supplier_id' => $supplierId));
         $supplierProductId = $supplierProduct->id;
         //			Create Detail
         //		Buat Product Detail
         $unitId = $fake->getFake()->randomElement($unitIds);
         $colorId = $fake->getFake()->randomElement($colorIds);
         $gradeId = $fake->getFake()->randomElement($gradeIds);
         $currSp = $fake->getFake()->randomElement($currencyIds);
         $currSpm = $fake->getFake()->randomElement($currencyIds);
         $detailIds[] = Productdetails::getIdOrCreate($productId, $colorId, $unitId, $gradeId, $currSp, $currSpm);
         //Buat Stock
         //		Buat Stock
         $stockIds[] = Stockproducts::createStock($productId);
     }
     foreach ($stockIds as $stockId) {
         for ($history = 0; $history < 9; $history++) {
             //		Buat Stock Detail/History
             if ($history % 2 == 0 || $history == 0) {
                 $typeHistory = 'in';
             } else {
                 $typeHistory = 'out';
             }
             $firstHistory = $history == 0;
             //                $stockHistoryIds[] =
             Stockproducthistory::createHistoryStockSample($stockId, $typeHistory, $firstHistory);
         }
     }
     return "Sudah Generate sebanyak " . count($productIds) . " records";
     return s($productIds, $supplierProductId, $imagesIds, $detailIds);
 }