mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 01:54:35 -04:00
Improve query efficiency
This commit is contained in:
parent
9c18ab7230
commit
e6be94ad22
@ -216,7 +216,7 @@ class PreviewController extends BaseController
|
|||||||
if(!$request->has('entity_id'))
|
if(!$request->has('entity_id'))
|
||||||
$entity_obj->service()->fillDefaults()->save();
|
$entity_obj->service()->fillDefaults()->save();
|
||||||
|
|
||||||
$entity_obj->load('client');
|
$entity_obj->load('client.contacts','company');
|
||||||
|
|
||||||
App::forgetInstance('translator');
|
App::forgetInstance('translator');
|
||||||
$t = app('translator');
|
$t = app('translator');
|
||||||
|
@ -74,12 +74,15 @@ class EmailPayment implements ShouldQueue
|
|||||||
|
|
||||||
MultiDB::setDb($this->company->db);
|
MultiDB::setDb($this->company->db);
|
||||||
|
|
||||||
|
$this->payment->load('invoices');
|
||||||
|
$this->contact->load('client');
|
||||||
|
|
||||||
$email_builder = (new PaymentEmailEngine($this->payment, $this->contact))->build();
|
$email_builder = (new PaymentEmailEngine($this->payment, $this->contact))->build();
|
||||||
|
|
||||||
$invitation = null;
|
$invitation = null;
|
||||||
|
|
||||||
if($this->payment->invoices()->exists())
|
if($this->payment->invoices && $this->payment->invoices->count() >=1)
|
||||||
$invitation = $this->payment->invoices()->first()->invitations()->first();
|
$invitation = $this->payment->invoices->first()->invitations()->first();
|
||||||
|
|
||||||
$nmo = new NinjaMailerObject;
|
$nmo = new NinjaMailerObject;
|
||||||
$nmo->mailable = new TemplateEmail($email_builder, $this->contact, $invitation);
|
$nmo->mailable = new TemplateEmail($email_builder, $this->contact, $invitation);
|
||||||
|
@ -47,6 +47,7 @@ class PaymentEmailEngine extends BaseEmailEngine
|
|||||||
$this->company = $payment->company;
|
$this->company = $payment->company;
|
||||||
$this->client = $payment->client;
|
$this->client = $payment->client;
|
||||||
$this->contact = $contact ?: $this->client->primary_contact()->first();
|
$this->contact = $contact ?: $this->client->primary_contact()->first();
|
||||||
|
$this->contact->load('client.company');
|
||||||
$this->settings = $this->client->getMergedSettings();
|
$this->settings = $this->client->getMergedSettings();
|
||||||
$this->template_data = $template_data;
|
$this->template_data = $template_data;
|
||||||
$this->helpers = new Helpers();
|
$this->helpers = new Helpers();
|
||||||
|
@ -84,12 +84,12 @@ class Client extends BaseModel implements HasLocalePreference
|
|||||||
];
|
];
|
||||||
|
|
||||||
protected $with = [
|
protected $with = [
|
||||||
'gateway_tokens',
|
// 'gateway_tokens',
|
||||||
'documents',
|
// 'documents',
|
||||||
'contacts.company',
|
// 'contacts.company',
|
||||||
// 'currency',
|
// 'currency',
|
||||||
// 'primary_contact',
|
// 'primary_contact',
|
||||||
'country',
|
// 'country',
|
||||||
// 'contacts',
|
// 'contacts',
|
||||||
// 'shipping_country',
|
// 'shipping_country',
|
||||||
// 'company',
|
// 'company',
|
||||||
|
@ -64,6 +64,10 @@ class Subscription extends BaseModel
|
|||||||
'deleted_at' => 'timestamp',
|
'deleted_at' => 'timestamp',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $with = [
|
||||||
|
'company',
|
||||||
|
];
|
||||||
|
|
||||||
public function service(): SubscriptionService
|
public function service(): SubscriptionService
|
||||||
{
|
{
|
||||||
return new SubscriptionService($this);
|
return new SubscriptionService($this);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user