Ejemplo n.º 1
0
 /**
  * @param bool $resultIds
  *
  * @return array|string
  * @throws \Exception
  */
 public static function generateMassive($resultIds = false)
 {
     $countries = Locations::where('level', 1);
     if (!$countries->count()) {
         throw new Exception('Negara Masih Kosong , Isi Dl');
     }
     $fake = static::getFake()->getCurrency();
     $ListCurrency = $fake->getCurrencies();
     $ids = array();
     foreach ($ListCurrency as $curr) {
         /*dapatkan ID*/
         $countryName = $curr['country'];
         $currName = $curr['name'];
         $currSymbol = $curr['symbol'];
         $country = Locations::whereName($countryName);
         if ($country->count()) {
             /*Jika Country Ada*/
             $countryId = $country->pluck('id');
             $record = $fake->createRecordCurrency($countryId, $currName, $currSymbol);
             $newrecord = static::createRecord($record);
             $ids[] = $newrecord->id;
         }
     }
     return $resultIds ? $ids : "Generate Currency with " . count($ids) . " records";
 }