mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-08 11:14:31 -04:00
Changes to support the mobile app
This commit is contained in:
parent
e39c07df79
commit
34b02ee8bf
@ -58,7 +58,7 @@ class $STUDLY_NAME$Repository extends BaseRepository
|
|||||||
$entity->save();
|
$entity->save();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (!$publicId || $publicId == '-1') {
|
if (!$publicId || intval($publicId) < 0) {
|
||||||
event(new ClientWasCreated($client));
|
event(new ClientWasCreated($client));
|
||||||
} else {
|
} else {
|
||||||
event(new ClientWasUpdated($client));
|
event(new ClientWasUpdated($client));
|
||||||
|
@ -264,7 +264,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 && intval($publicId) > 0) {
|
||||||
$contact = Contact::scope($publicId)->whereClientId($this->id)->firstOrFail();
|
$contact = Contact::scope($publicId)->whereClientId($this->id)->firstOrFail();
|
||||||
} else {
|
} else {
|
||||||
$contact = Contact::createNew();
|
$contact = Contact::createNew();
|
||||||
|
@ -219,7 +219,7 @@ 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 (! $this->wasRecentlyCreated && $publicId && $publicId != '-1') {
|
if (! $this->wasRecentlyCreated && $publicId && intval($publicId) > 0) {
|
||||||
$contact = VendorContact::scope($publicId)->whereVendorId($this->id)->firstOrFail();
|
$contact = VendorContact::scope($publicId)->whereVendorId($this->id)->firstOrFail();
|
||||||
} else {
|
} else {
|
||||||
$contact = VendorContact::createNew();
|
$contact = VendorContact::createNew();
|
||||||
|
@ -87,7 +87,7 @@ class ClientRepository extends BaseRepository
|
|||||||
|
|
||||||
if ($client) {
|
if ($client) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} elseif (! $publicId || $publicId == '-1') {
|
} elseif (! $publicId || intval($publicId) < 0) {
|
||||||
$client = Client::createNew();
|
$client = Client::createNew();
|
||||||
} else {
|
} else {
|
||||||
$client = Client::scope($publicId)->with('contacts')->firstOrFail();
|
$client = Client::scope($publicId)->with('contacts')->firstOrFail();
|
||||||
@ -176,7 +176,7 @@ class ClientRepository extends BaseRepository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $publicId || $publicId == '-1') {
|
if (! $publicId || intval($publicId) < 0) {
|
||||||
event(new ClientWasCreated($client));
|
event(new ClientWasCreated($client));
|
||||||
} else {
|
} else {
|
||||||
event(new ClientWasUpdated($client));
|
event(new ClientWasUpdated($client));
|
||||||
|
@ -19,7 +19,7 @@ class ContactRepository extends BaseRepository
|
|||||||
|
|
||||||
if ($contact) {
|
if ($contact) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} elseif (! $publicId || $publicId == '-1') {
|
} elseif (! $publicId || intval($publicId) < 0) {
|
||||||
$contact = Contact::createNew();
|
$contact = Contact::createNew();
|
||||||
$contact->send_invoice = true;
|
$contact->send_invoice = true;
|
||||||
$contact->client_id = $data['client_id'];
|
$contact->client_id = $data['client_id'];
|
||||||
|
@ -381,7 +381,7 @@ class InvoiceRepository extends BaseRepository
|
|||||||
@file_put_contents(storage_path('logs/invoice-repo.log'), $logMessage, FILE_APPEND);
|
@file_put_contents(storage_path('logs/invoice-repo.log'), $logMessage, FILE_APPEND);
|
||||||
}
|
}
|
||||||
|
|
||||||
$isNew = ! $publicId || $publicId == '-1';
|
$isNew = ! $publicId || inval($publicId) < 0;
|
||||||
|
|
||||||
if ($invoice) {
|
if ($invoice) {
|
||||||
// do nothing
|
// do nothing
|
||||||
|
@ -12,7 +12,7 @@ class VendorContactRepository extends BaseRepository
|
|||||||
{
|
{
|
||||||
$publicId = isset($data['public_id']) ? $data['public_id'] : false;
|
$publicId = isset($data['public_id']) ? $data['public_id'] : false;
|
||||||
|
|
||||||
if (! $publicId || $publicId == '-1') {
|
if (! $publicId || intval($publicId) < 0) {
|
||||||
$contact = VendorContact::createNew();
|
$contact = VendorContact::createNew();
|
||||||
//$contact->send_invoice = true;
|
//$contact->send_invoice = true;
|
||||||
$contact->vendor_id = $data['vendor_id'];
|
$contact->vendor_id = $data['vendor_id'];
|
||||||
|
@ -68,7 +68,7 @@ class VendorRepository extends BaseRepository
|
|||||||
|
|
||||||
if ($vendor) {
|
if ($vendor) {
|
||||||
// do nothing
|
// do nothing
|
||||||
} elseif (! $publicId || $publicId == '-1') {
|
} elseif (! $publicId || intval($publicId) < 0) {
|
||||||
$vendor = Vendor::createNew();
|
$vendor = Vendor::createNew();
|
||||||
} else {
|
} else {
|
||||||
$vendor = Vendor::scope($publicId)->with('vendor_contacts')->firstOrFail();
|
$vendor = Vendor::scope($publicId)->with('vendor_contacts')->firstOrFail();
|
||||||
|
@ -84,7 +84,7 @@ class InvoiceService extends BaseService
|
|||||||
$canSaveClient = false;
|
$canSaveClient = false;
|
||||||
$canViewClient = false;
|
$canViewClient = false;
|
||||||
$clientPublicId = array_get($data, 'client.public_id') ?: array_get($data, 'client.id');
|
$clientPublicId = array_get($data, 'client.public_id') ?: array_get($data, 'client.id');
|
||||||
if (empty($clientPublicId) || $clientPublicId == '-1') {
|
if (empty($clientPublicId) || intval($clientPublicId) < 0) {
|
||||||
$canSaveClient = Auth::user()->can('create', ENTITY_CLIENT);
|
$canSaveClient = Auth::user()->can('create', ENTITY_CLIENT);
|
||||||
} else {
|
} else {
|
||||||
$client = Client::scope($clientPublicId)->first();
|
$client = Client::scope($clientPublicId)->first();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user