From f4fd45118cd63aacd20115b5c3cdd029bfc6c580 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Mon, 29 Feb 2016 12:01:43 +0200 Subject: [PATCH] Added support for currency_code in API --- app/Ninja/Repositories/ClientRepository.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/Ninja/Repositories/ClientRepository.php b/app/Ninja/Repositories/ClientRepository.php index 324d62a45943..2e8ce31b5c1c 100644 --- a/app/Ninja/Repositories/ClientRepository.php +++ b/app/Ninja/Repositories/ClientRepository.php @@ -1,6 +1,7 @@ with('contacts')->firstOrFail(); } + // convert currency code to id + if (isset($data['currency_code'])) { + $currencyCode = strtolower($data['currency_code']); + $currency = Cache::get('currencies')->filter(function($item) use ($currencyCode) { + return strtolower($item->code) == $currencyCode; + })->first(); + if ($currency) { + $data['currency_id'] = $currency->id; + } + } + $client->fill($data); $client->save();