From 8d9950ebbdfbbabc72788cbf77e9c5790b6413f1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 14 Jul 2021 08:39:30 +1000 Subject: [PATCH] Add company country as default if none is set --- app/Repositories/ClientRepository.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Repositories/ClientRepository.php b/app/Repositories/ClientRepository.php index d2a904a9857b..5074e2976ba4 100644 --- a/app/Repositories/ClientRepository.php +++ b/app/Repositories/ClientRepository.php @@ -58,6 +58,10 @@ class ClientRepository extends BaseRepository return $client; } + if(!$client->id && (!array_key_exists('country_id', $data) || empty($data['country_id']))){ + $data['country_id'] = auth()->user()->company()->settings->country_id; + } + $client->fill($data); if (!isset($client->number) || empty($client->number)) {