mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Added relationLoaded checks to optimize queries
This commit is contained in:
parent
7744c6c41c
commit
2a5de605dc
@ -9,7 +9,7 @@ class ClientRequest extends EntityRequest {
|
|||||||
$client = parent::entity();
|
$client = parent::entity();
|
||||||
|
|
||||||
// eager load the contacts
|
// eager load the contacts
|
||||||
if ($client && ! count($client->contacts)) {
|
if ($client && ! $client->relationLoaded('contacts')) {
|
||||||
$client->load('contacts');
|
$client->load('contacts');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ class ExpenseRequest extends EntityRequest {
|
|||||||
{
|
{
|
||||||
$expense = parent::entity();
|
$expense = parent::entity();
|
||||||
|
|
||||||
// eager load the contacts
|
// eager load the documents
|
||||||
if ($expense && ! count($expense->documents)) {
|
if ($expense && ! $expense->relationLoaded('documents')) {
|
||||||
$expense->load('documents');
|
$expense->load('documents');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,8 +8,8 @@ class InvoiceRequest extends EntityRequest {
|
|||||||
{
|
{
|
||||||
$invoice = parent::entity();
|
$invoice = parent::entity();
|
||||||
|
|
||||||
// eager load the contacts
|
// eager load the invoice items
|
||||||
if ($invoice && ! count($invoice->invoice_items)) {
|
if ($invoice && ! $invoice->relationLoaded('invoice_items')) {
|
||||||
$invoice->load('invoice_items');
|
$invoice->load('invoice_items');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class VendorRequest extends EntityRequest {
|
|||||||
$vendor = parent::entity();
|
$vendor = parent::entity();
|
||||||
|
|
||||||
// eager load the contacts
|
// eager load the contacts
|
||||||
if ($vendor && ! count($vendor->vendor_contacts)) {
|
if ($vendor && ! $vendor->relationLoaded('vendor_contacts')) {
|
||||||
$vendor->load('vendor_contacts');
|
$vendor->load('vendor_contacts');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +212,9 @@ class Account extends Eloquent
|
|||||||
|
|
||||||
public function isGatewayConfigured($gatewayId = 0)
|
public function isGatewayConfigured($gatewayId = 0)
|
||||||
{
|
{
|
||||||
|
if ( ! $this->relationLoaded('account_gateways')) {
|
||||||
$this->load('account_gateways');
|
$this->load('account_gateways');
|
||||||
|
}
|
||||||
|
|
||||||
if ($gatewayId) {
|
if ($gatewayId) {
|
||||||
return $this->getGatewayConfig($gatewayId) != false;
|
return $this->getGatewayConfig($gatewayId) != false;
|
||||||
@ -241,7 +243,7 @@ class Account extends Eloquent
|
|||||||
return $this->name;
|
return $this->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->load('users');
|
//$this->load('users');
|
||||||
$user = $this->users()->first();
|
$user = $this->users()->first();
|
||||||
|
|
||||||
return $user->getDisplayName();
|
return $user->getDisplayName();
|
||||||
|
@ -256,13 +256,17 @@ class Client extends EntityModel
|
|||||||
|
|
||||||
public function getGatewayToken()
|
public function getGatewayToken()
|
||||||
{
|
{
|
||||||
$this->account->load('account_gateways');
|
$account = $this->account;
|
||||||
|
|
||||||
if (!count($this->account->account_gateways)) {
|
if ( ! $account->relationLoaded('account_gateways')) {
|
||||||
|
$account->load('account_gateways');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!count($account->account_gateways)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$accountGateway = $this->account->getGatewayConfig(GATEWAY_STRIPE);
|
$accountGateway = $account->getGatewayConfig(GATEWAY_STRIPE);
|
||||||
|
|
||||||
if (!$accountGateway) {
|
if (!$accountGateway) {
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user