mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Added support for currency_code in API
This commit is contained in:
parent
16da4fcbfe
commit
f4fd45118c
@ -1,6 +1,7 @@
|
||||
<?php namespace App\Ninja\Repositories;
|
||||
|
||||
use DB;
|
||||
use Cache;
|
||||
use App\Ninja\Repositories\BaseRepository;
|
||||
use App\Models\Client;
|
||||
use App\Models\Contact;
|
||||
@ -74,6 +75,17 @@ class ClientRepository extends BaseRepository
|
||||
$client = Client::scope($publicId)->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();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user