1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

Prevent creating clients without contacts

This commit is contained in:
Hillel Coren 2017-08-07 14:04:33 +03:00
parent 80010880bb
commit 252c6f0a56

View File

@ -244,7 +244,9 @@ class Client extends EntityModel
{
$publicId = isset($data['public_id']) ? $data['public_id'] : (isset($data['id']) ? $data['id'] : false);
if ($publicId && $publicId != '-1') {
// check if this client wasRecentlyCreated to ensure a new contact is
// always created even if the request includes a contact id
if (! $this->wasRecentlyCreated && $publicId && $publicId != '-1') {
$contact = Contact::scope($publicId)->firstOrFail();
} else {
$contact = Contact::createNew();