mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-12 22:22:32 +01:00
Fixes for coercing types for react UI
This commit is contained in:
parent
1ce2f789d4
commit
9722289796
@ -22,6 +22,7 @@ use App\Models\Quote;
|
||||
use App\Models\Task;
|
||||
use App\Services\Client\ClientService;
|
||||
use App\Utils\Traits\AppSetup;
|
||||
use App\Utils\Traits\ClientGroupSettingsSaver;
|
||||
use App\Utils\Traits\GeneratesCounter;
|
||||
use App\Utils\Traits\MakesDates;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
@ -40,6 +41,7 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
use Filterable;
|
||||
use GeneratesCounter;
|
||||
use AppSetup;
|
||||
use ClientGroupSettingsSaver;
|
||||
|
||||
protected $presenter = ClientPresenter::class;
|
||||
|
||||
|
@ -14,6 +14,7 @@ namespace App\Repositories;
|
||||
use App\Factory\ClientFactory;
|
||||
use App\Models\Client;
|
||||
use App\Models\Company;
|
||||
use App\Utils\Traits\ClientGroupSettingsSaver;
|
||||
use App\Utils\Traits\GeneratesCounter;
|
||||
use App\Utils\Traits\SavesDocuments;
|
||||
|
||||
@ -61,10 +62,14 @@ class ClientRepository extends BaseRepository
|
||||
|
||||
$client->fill($data);
|
||||
|
||||
|
||||
if (array_key_exists('settings', $data)) {
|
||||
$client->saveSettings($data['settings'], $client);
|
||||
}
|
||||
|
||||
if(!$client->country_id){
|
||||
$company = Company::find($client->company_id);
|
||||
$client->country_id = $company->settings->country_id;
|
||||
|
||||
}
|
||||
|
||||
$client->save();
|
||||
|
@ -104,6 +104,11 @@ trait ClientGroupSettingsSaver
|
||||
}
|
||||
|
||||
foreach ($casts as $key => $value) {
|
||||
|
||||
if($value == 'float' && property_exists($settings, $key)){
|
||||
$settings->{$key} = floatval($settings->{$key});
|
||||
}
|
||||
|
||||
if (in_array($key, CompanySettings::$string_casts)) {
|
||||
$value = 'string';
|
||||
|
||||
@ -160,6 +165,10 @@ trait ClientGroupSettingsSaver
|
||||
|
||||
foreach ($casts as $key => $value) {
|
||||
|
||||
if($value == 'float' && property_exists($settings, $key)){
|
||||
$settings->{$key} = floatval($settings->{$key});
|
||||
}
|
||||
|
||||
/*Separate loop if it is a _id field which is an integer cast as a string*/
|
||||
if (substr($key, -3) == '_id' || substr($key, -14) == 'number_counter') {
|
||||
$value = 'integer';
|
||||
|
Loading…
Reference in New Issue
Block a user