mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -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'))
|
||||
$entity_obj->service()->fillDefaults()->save();
|
||||
|
||||
$entity_obj->load('client');
|
||||
$entity_obj->load('client.contacts','company');
|
||||
|
||||
App::forgetInstance('translator');
|
||||
$t = app('translator');
|
||||
|
@ -74,12 +74,15 @@ class EmailPayment implements ShouldQueue
|
||||
|
||||
MultiDB::setDb($this->company->db);
|
||||
|
||||
$this->payment->load('invoices');
|
||||
$this->contact->load('client');
|
||||
|
||||
$email_builder = (new PaymentEmailEngine($this->payment, $this->contact))->build();
|
||||
|
||||
$invitation = null;
|
||||
|
||||
if($this->payment->invoices()->exists())
|
||||
$invitation = $this->payment->invoices()->first()->invitations()->first();
|
||||
if($this->payment->invoices && $this->payment->invoices->count() >=1)
|
||||
$invitation = $this->payment->invoices->first()->invitations()->first();
|
||||
|
||||
$nmo = new NinjaMailerObject;
|
||||
$nmo->mailable = new TemplateEmail($email_builder, $this->contact, $invitation);
|
||||
|
@ -47,6 +47,7 @@ class PaymentEmailEngine extends BaseEmailEngine
|
||||
$this->company = $payment->company;
|
||||
$this->client = $payment->client;
|
||||
$this->contact = $contact ?: $this->client->primary_contact()->first();
|
||||
$this->contact->load('client.company');
|
||||
$this->settings = $this->client->getMergedSettings();
|
||||
$this->template_data = $template_data;
|
||||
$this->helpers = new Helpers();
|
||||
|
@ -84,12 +84,12 @@ class Client extends BaseModel implements HasLocalePreference
|
||||
];
|
||||
|
||||
protected $with = [
|
||||
'gateway_tokens',
|
||||
'documents',
|
||||
'contacts.company',
|
||||
// 'gateway_tokens',
|
||||
// 'documents',
|
||||
// 'contacts.company',
|
||||
// 'currency',
|
||||
// 'primary_contact',
|
||||
'country',
|
||||
// 'country',
|
||||
// 'contacts',
|
||||
// 'shipping_country',
|
||||
// 'company',
|
||||
|
@ -64,6 +64,10 @@ class Subscription extends BaseModel
|
||||
'deleted_at' => 'timestamp',
|
||||
];
|
||||
|
||||
protected $with = [
|
||||
'company',
|
||||
];
|
||||
|
||||
public function service(): SubscriptionService
|
||||
{
|
||||
return new SubscriptionService($this);
|
||||
|
Loading…
x
Reference in New Issue
Block a user