Add check to prevent changing contact’s client id

This commit is contained in:
Hillel Coren 2018-03-26 22:31:24 +03:00
parent 08aed19f9a
commit c7f5a5cd9c
2 changed files with 3 additions and 3 deletions

View File

@ -262,7 +262,7 @@ class Client extends EntityModel
// check if this client wasRecentlyCreated to ensure a new contact is // check if this client wasRecentlyCreated to ensure a new contact is
// always created even if the request includes a contact id // always created even if the request includes a contact id
if (! $this->wasRecentlyCreated && $publicId && $publicId != '-1') { if (! $this->wasRecentlyCreated && $publicId && $publicId != '-1') {
$contact = Contact::scope($publicId)->firstOrFail(); $contact = Contact::scope($publicId)->whereClientId($this->id)->firstOrFail();
} else { } else {
$contact = Contact::createNew(); $contact = Contact::createNew();
$contact->send_invoice = true; $contact->send_invoice = true;

View File

@ -216,8 +216,8 @@ class Vendor extends EntityModel
{ {
$publicId = isset($data['public_id']) ? $data['public_id'] : (isset($data['id']) ? $data['id'] : false); $publicId = isset($data['public_id']) ? $data['public_id'] : (isset($data['id']) ? $data['id'] : false);
if ($publicId && $publicId != '-1') { if (! $this->wasRecentlyCreated && $publicId && $publicId != '-1') {
$contact = VendorContact::scope($publicId)->firstOrFail(); $contact = VendorContact::scope($publicId)->whereVendorId($this->id)->firstOrFail();
} else { } else {
$contact = VendorContact::createNew(); $contact = VendorContact::createNew();
} }