mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-09-19 16:01:34 +02: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();
|
||||
|
||||
/*
|
||||
if (!$publicId || $publicId == '-1') {
|
||||
if (!$publicId || intval($publicId) < 0) {
|
||||
event(new ClientWasCreated($client));
|
||||
} else {
|
||||
event(new ClientWasUpdated($client));
|
||||
|
@ -264,7 +264,7 @@ class Client extends EntityModel
|
||||
|
||||
// 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') {
|
||||
if (! $this->wasRecentlyCreated && $publicId && intval($publicId) > 0) {
|
||||
$contact = Contact::scope($publicId)->whereClientId($this->id)->firstOrFail();
|
||||
} else {
|
||||
$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);
|
||||
|
||||
if (! $this->wasRecentlyCreated && $publicId && $publicId != '-1') {
|
||||
if (! $this->wasRecentlyCreated && $publicId && intval($publicId) > 0) {
|
||||
$contact = VendorContact::scope($publicId)->whereVendorId($this->id)->firstOrFail();
|
||||
} else {
|
||||
$contact = VendorContact::createNew();
|
||||
|
@ -87,7 +87,7 @@ class ClientRepository extends BaseRepository
|
||||
|
||||
if ($client) {
|
||||
// do nothing
|
||||
} elseif (! $publicId || $publicId == '-1') {
|
||||
} elseif (! $publicId || intval($publicId) < 0) {
|
||||
$client = Client::createNew();
|
||||
} else {
|
||||
$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));
|
||||
} else {
|
||||
event(new ClientWasUpdated($client));
|
||||
|
@ -19,7 +19,7 @@ class ContactRepository extends BaseRepository
|
||||
|
||||
if ($contact) {
|
||||
// do nothing
|
||||
} elseif (! $publicId || $publicId == '-1') {
|
||||
} elseif (! $publicId || intval($publicId) < 0) {
|
||||
$contact = Contact::createNew();
|
||||
$contact->send_invoice = true;
|
||||
$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);
|
||||
}
|
||||
|
||||
$isNew = ! $publicId || $publicId == '-1';
|
||||
$isNew = ! $publicId || inval($publicId) < 0;
|
||||
|
||||
if ($invoice) {
|
||||
// do nothing
|
||||
|
@ -12,7 +12,7 @@ class VendorContactRepository extends BaseRepository
|
||||
{
|
||||
$publicId = isset($data['public_id']) ? $data['public_id'] : false;
|
||||
|
||||
if (! $publicId || $publicId == '-1') {
|
||||
if (! $publicId || intval($publicId) < 0) {
|
||||
$contact = VendorContact::createNew();
|
||||
//$contact->send_invoice = true;
|
||||
$contact->vendor_id = $data['vendor_id'];
|
||||
|
@ -68,7 +68,7 @@ class VendorRepository extends BaseRepository
|
||||
|
||||
if ($vendor) {
|
||||
// do nothing
|
||||
} elseif (! $publicId || $publicId == '-1') {
|
||||
} elseif (! $publicId || intval($publicId) < 0) {
|
||||
$vendor = Vendor::createNew();
|
||||
} else {
|
||||
$vendor = Vendor::scope($publicId)->with('vendor_contacts')->firstOrFail();
|
||||
|
@ -84,7 +84,7 @@ class InvoiceService extends BaseService
|
||||
$canSaveClient = false;
|
||||
$canViewClient = false;
|
||||
$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);
|
||||
} else {
|
||||
$client = Client::scope($clientPublicId)->first();
|
||||
|
Loading…
Reference in New Issue
Block a user