$value]); /** @var CurrencyRepositoryInterface $repository */ $repository = app(CurrencyRepositoryInterface::class); if (isset($this->mapping[$value])) { Log::debug('Found currency in mapping. Should exist.', ['value' => $value, 'map' => $this->mapping[$value]]); $currency = $repository->find(intval($this->mapping[$value])); if (!is_null($currency->id)) { Log::debug('Found currency by ID', ['id' => $currency->id]); $this->setCertainty(100); return $currency; } } // not mapped? Still try to find it first: $currency = $repository->findByCode($value); if (!is_null($currency->id)) { Log::debug('Found currency by code', ['id' => $currency->id]); $this->setCertainty(100); return $currency; } $currency = $repository->store( [ 'name' => $value, 'code' => $value, 'symbol' => $value, ] ); $this->setCertainty(100); return $currency; } }