mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 06:24:35 -04: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\Models\Task;
|
||||||
use App\Services\Client\ClientService;
|
use App\Services\Client\ClientService;
|
||||||
use App\Utils\Traits\AppSetup;
|
use App\Utils\Traits\AppSetup;
|
||||||
|
use App\Utils\Traits\ClientGroupSettingsSaver;
|
||||||
use App\Utils\Traits\GeneratesCounter;
|
use App\Utils\Traits\GeneratesCounter;
|
||||||
use App\Utils\Traits\MakesDates;
|
use App\Utils\Traits\MakesDates;
|
||||||
use App\Utils\Traits\MakesHash;
|
use App\Utils\Traits\MakesHash;
|
||||||
@ -40,6 +41,7 @@ class Client extends BaseModel implements HasLocalePreference
|
|||||||
use Filterable;
|
use Filterable;
|
||||||
use GeneratesCounter;
|
use GeneratesCounter;
|
||||||
use AppSetup;
|
use AppSetup;
|
||||||
|
use ClientGroupSettingsSaver;
|
||||||
|
|
||||||
protected $presenter = ClientPresenter::class;
|
protected $presenter = ClientPresenter::class;
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@ namespace App\Repositories;
|
|||||||
use App\Factory\ClientFactory;
|
use App\Factory\ClientFactory;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
|
use App\Utils\Traits\ClientGroupSettingsSaver;
|
||||||
use App\Utils\Traits\GeneratesCounter;
|
use App\Utils\Traits\GeneratesCounter;
|
||||||
use App\Utils\Traits\SavesDocuments;
|
use App\Utils\Traits\SavesDocuments;
|
||||||
|
|
||||||
@ -61,10 +62,14 @@ class ClientRepository extends BaseRepository
|
|||||||
|
|
||||||
$client->fill($data);
|
$client->fill($data);
|
||||||
|
|
||||||
|
|
||||||
|
if (array_key_exists('settings', $data)) {
|
||||||
|
$client->saveSettings($data['settings'], $client);
|
||||||
|
}
|
||||||
|
|
||||||
if(!$client->country_id){
|
if(!$client->country_id){
|
||||||
$company = Company::find($client->company_id);
|
$company = Company::find($client->company_id);
|
||||||
$client->country_id = $company->settings->country_id;
|
$client->country_id = $company->settings->country_id;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$client->save();
|
$client->save();
|
||||||
|
@ -104,6 +104,11 @@ trait ClientGroupSettingsSaver
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($casts as $key => $value) {
|
foreach ($casts as $key => $value) {
|
||||||
|
|
||||||
|
if($value == 'float' && property_exists($settings, $key)){
|
||||||
|
$settings->{$key} = floatval($settings->{$key});
|
||||||
|
}
|
||||||
|
|
||||||
if (in_array($key, CompanySettings::$string_casts)) {
|
if (in_array($key, CompanySettings::$string_casts)) {
|
||||||
$value = 'string';
|
$value = 'string';
|
||||||
|
|
||||||
@ -160,6 +165,10 @@ trait ClientGroupSettingsSaver
|
|||||||
|
|
||||||
foreach ($casts as $key => $value) {
|
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*/
|
/*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') {
|
if (substr($key, -3) == '_id' || substr($key, -14) == 'number_counter') {
|
||||||
$value = 'integer';
|
$value = 'integer';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user