diff --git a/app/Factory/ClientFactory.php b/app/Factory/ClientFactory.php index 35b600618c87..b27d0101a9c2 100644 --- a/app/Factory/ClientFactory.php +++ b/app/Factory/ClientFactory.php @@ -28,7 +28,7 @@ class ClientFactory $client->public_notes = ''; $client->balance = 0; $client->paid_to_date = 0; - $client->country_id = 840; + $client->country_id = null; $client->is_deleted = 0; $client->client_hash = Str::random(40); $client->settings = ClientSettings::defaults(); diff --git a/app/Repositories/ClientRepository.php b/app/Repositories/ClientRepository.php index cd2bd9bff13d..811b43edaacf 100644 --- a/app/Repositories/ClientRepository.php +++ b/app/Repositories/ClientRepository.php @@ -58,11 +58,11 @@ class ClientRepository extends BaseRepository return $client; } - if(!$client->id && auth()->user() && auth()->user()->company() && (!array_key_exists('country_id', $data) || empty($data['country_id']))){ - $data['country_id'] = auth()->user()->company()->settings->country_id; - } - $client->fill($data); + + if(!$client->country_id) + $client->country_id = auth()->user()->company()->settings->country_id; + $client->save(); if (!isset($client->number) || empty($client->number) || strlen($client->number) == 0) {