/** * @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"; }
/** * @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"; }
/** * @return int|mixed */ public static function getDefaultWarehouseIdOrCreate() { $id = static::Name(static::$defaultName)->pluck('id'); if (null == $id) { /* Create Record */ $countryId = Locations::getIdsDefaultCountryOrCreate(); $provinceId = Locations::getIdsDefaultProvinceOrCreate($countryId); $cityId = Locations::getIdsDefaultCityOrCreate($provinceId); $catId = Warehousecategory::getIdDefaultWarehouseCategoryOrCreate(); $wh = static::create(static::getFake()->getWarehouse()->createWarehouse(static::$defaultName, $cityId, $catId)); $id = $wh->id; } return $id; }