diff --git a/app/Http/Requests/Client/StoreClientRequest.php b/app/Http/Requests/Client/StoreClientRequest.php index 64c2b2eb3aac..790415f0c675 100644 --- a/app/Http/Requests/Client/StoreClientRequest.php +++ b/app/Http/Requests/Client/StoreClientRequest.php @@ -36,7 +36,7 @@ class StoreClientRequest extends Request /* Ensure we have a client name, and that all emails are unique*/ $rules['name'] = 'required|min:1'; - $rules['id_number'] = 'unique:clients,id_number,,id,company_id,' . auth()->user()->company()->id; + $rules['id_number'] = 'unique:clients,id_number,' . $this->id . ',id,company_id,' . $this->company_id; //$rules['settings'] = 'json'; $contacts = request('contacts'); diff --git a/app/Repositories/ClientRepository.php b/app/Repositories/ClientRepository.php index ea6a58f80a68..f2da7ecdf78b 100644 --- a/app/Repositories/ClientRepository.php +++ b/app/Repositories/ClientRepository.php @@ -65,8 +65,8 @@ class ClientRepository extends BaseRepository $client->save(); - // if($client->id_number == "") - // $client->id_number = $this->getNextClientNumber($client); //todo write tests for this and make sure that custom client numbers also works as expected from here + if($client->id_number == "" || !$client->id_number) + $client->id_number = $this->getNextClientNumber($client); //todo write tests for this and make sure that custom client numbers also works as expected from here $client->save();