Exemple #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();
     }
 }
Exemple #2
0
 /**
  * Generate Data Massive Contact Person
  *
  * @param bool $resultIds
  *
  * @param int  $count
  *
  * @return array|string
  */
 public static function generateMassive($resultIds = false, $count = 100)
 {
     $posIds = Positions::getIdsPositionOrCreateMassiveDummy();
     $deptIds = Dept::getIdsOrCreateMassiveDummy();
     $supplierIds = Suppliers::getRecordIdsOrCreate(200);
     $buyerIds = Buyers::getRecordIdsOrCreate(200);
     $records = static::getFake()->getContacts()->generateContacts($count, $posIds, $deptIds, $supplierIds, $buyerIds);
     $contacts = array();
     foreach ($records as $record) {
         $newrecord = static::create($record);
         $contacts[] = $newrecord->id;
     }
     return $resultIds ? $contacts : 'Generate Contact Person with ' . count($contacts) . ' records';
 }
Exemple #3
0
 /**
  * @param int $count
  *
  * @return array
  */
 public static function createSampleAccountBank($count = 10)
 {
     $sample = static::getSample()->getFake();
     $listBanksId = Bank::getIdsOrCreateBanks(true);
     $listtypeId = Bankaccounttype::getDefaultBankTypeIdsOrCreate(true);
     $buyerIds = Buyers::getRecordIdsOrCreate(30);
     $supplierIds = Suppliers::getRecordIdsOrCreate();
     $ids = array();
     for ($rec = 0; $rec < $count; $rec++) {
         $bankId = $sample->randomElement($listBanksId);
         $TypeId = $sample->randomElement($listtypeId);
         $buyerId = $sample->randomElement($buyerIds);
         $supplierId = $sample->randomElement($supplierIds);
         $parents = static::getSample()->getBank()->getListOwners($supplierId, $buyerId);
         $parentId = $parents['id'];
         $parentType = $parents['type'];
         $records = static::create(static::getSample()->getBank()->createAccountBank($bankId, $parentId, $parentType, $TypeId));
         $ids[] = $records->id;
     }
     return $ids;
     //		$bankId,$parentId, $parentType, $typeId
 }
Exemple #4
0
 public static function generateMassivePhoneSample($resultIds = false, $count = 10)
 {
     $listBuyerIds = Buyers::getRecordIdsOrCreate();
     $listSupplierIds = Suppliers::getRecordIdsOrCreate();
     $ids = array();
     for ($r = 0; $r < $count; $r++) {
         $buyerId = static::pickOneFromArray($listBuyerIds);
         $supplierId = static::pickOneFromArray($listSupplierIds);
         $parents = static::getParentRecord($buyerId, $supplierId);
         $parent = $parents[rand(0, 1)];
         $parentId = $parent['id'];
         $parentType = $parent['type'];
         $newrecord = static::createRecord(static::getRecordValue($parentId, $parentType));
         $ids[] = $newrecord->id;
     }
     $total = count($ids);
     return $resultIds ? $ids : "Generate Phone with {$total} record ";
 }
Exemple #5
0
     $json = $ba->getSupplier(1)->get()->toJson();
     //            $json = $ba->getBuyer(1)->get()->toJson();
     return $json;
     //            $supplier = \Emayk\Ics\Repo\Suppliers\Suppliers::find(1);
     //            $accountbank =$supplier->accountbank;
     //
     //                accountbank
     //            get accountbank supplier
     //            \Emayk\Ics\Repo\Bankaccount\Bankaccount::scopeSuppliers
     //generate
     //            return \Emayk\Ics\Repo\Suppliers\Suppliers::generateMassiveDummy(false,50);
 });
 Route::get('buyer', function () use($fake) {
     //            $fake = \Faker\Factory::create();
     //            return $fake->text;
     return \Emayk\Ics\Repo\Buyers\Buyers::generateDummyData(false, 100);
 });
 Route::get('fabric', function () {
     //			return \Emayk\Ics\Repo\Fabricgrade\Fabricgrade::generateMassive(true);
     //			return \Emayk\Ics\Repo\Fabrictype\Fabrictype::generateMassive();
 });
 /**
  * Generate Legality
  * $ids = true, menghasilkan array berisi id yang telah dibuat;
  * \Emayk\Ics\Repo\Legality\Legality::generateMassiveLegality($ids)
  */
 Route::get('legality', function () {
     return \Emayk\Ics\Repo\Legality\Legality::generateMassiveLegality();
 });
 /**
  * Generate Locations