mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Add bank integrations into default includes
This commit is contained in:
parent
c0cb157309
commit
3542e35da0
@ -105,6 +105,7 @@ class BaseController extends Controller
|
||||
'company.vendors.documents',
|
||||
'company.webhooks',
|
||||
'company.system_logs',
|
||||
'company.bank_integrations',
|
||||
];
|
||||
|
||||
private $mini_load = [
|
||||
@ -122,6 +123,7 @@ class BaseController extends Controller
|
||||
'company.designs.company',
|
||||
'company.expense_categories',
|
||||
'company.subscriptions',
|
||||
'company.bank_integrations',
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
@ -438,6 +440,13 @@ class BaseController extends Controller
|
||||
$query->where('subscriptions.user_id', $user->id);
|
||||
}
|
||||
},
|
||||
'company.bank_integrations'=> function ($query) use ($updated_at, $user) {
|
||||
$query->whereNotNull('updated_at');
|
||||
|
||||
if (! $user->isAdmin()) {
|
||||
$query->where('bank_integrations.user_id', $user->id);
|
||||
}
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
@ -497,6 +506,12 @@ class BaseController extends Controller
|
||||
$query->where('activities.user_id', $user->id);
|
||||
}
|
||||
},
|
||||
'company.bank_integrations'=> function ($query) use ($created_at, $user) {
|
||||
|
||||
if (! $user->isAdmin()) {
|
||||
$query->where('bank_integrations.user_id', $user->id);
|
||||
}
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
@ -741,6 +756,13 @@ class BaseController extends Controller
|
||||
|
||||
}
|
||||
},
|
||||
'company.bank_integrations'=> function ($query) use ($created_at, $user) {
|
||||
$query->where('created_at', '>=', $created_at);
|
||||
|
||||
if (! $user->isAdmin()) {
|
||||
$query->where('bank_integrations.user_id', $user->id);
|
||||
}
|
||||
},
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -176,6 +176,11 @@ class Company extends BaseModel
|
||||
return $this->hasMany(CompanyLedger::class);
|
||||
}
|
||||
|
||||
public function bank_integrations()
|
||||
{
|
||||
return $this->hasMany(BankIntegration::class);
|
||||
}
|
||||
|
||||
public function getCompanyIdAttribute()
|
||||
{
|
||||
return $this->encodePrimaryKey($this->id);
|
||||
|
@ -13,6 +13,7 @@ namespace App\Transformers;
|
||||
|
||||
use App\Models\Account;
|
||||
use App\Models\Activity;
|
||||
use App\Models\BankIntegration;
|
||||
use App\Models\Client;
|
||||
use App\Models\Company;
|
||||
use App\Models\CompanyGateway;
|
||||
@ -40,6 +41,7 @@ use App\Models\TaskStatus;
|
||||
use App\Models\TaxRate;
|
||||
use App\Models\User;
|
||||
use App\Models\Webhook;
|
||||
use App\Transformers\BankIntegrationTransformer;
|
||||
use App\Transformers\PurchaseOrderTransformer;
|
||||
use App\Transformers\RecurringExpenseTransformer;
|
||||
use App\Utils\Traits\MakesHash;
|
||||
@ -98,6 +100,7 @@ class CompanyTransformer extends EntityTransformer
|
||||
'subscriptions',
|
||||
'recurring_expenses',
|
||||
'purchase_orders',
|
||||
'bank_integrations',
|
||||
];
|
||||
|
||||
/**
|
||||
@ -217,6 +220,13 @@ class CompanyTransformer extends EntityTransformer
|
||||
return $this->includeCollection($company->tokens, $transformer, CompanyToken::class);
|
||||
}
|
||||
|
||||
public function includeBankIntegrations(Company $company)
|
||||
{
|
||||
$transformer = new BankIntegrationTransformer($this->serializer);
|
||||
|
||||
return $this->includeCollection($company->bank_integrations, $transformer, BankIntegration::class);
|
||||
}
|
||||
|
||||
public function includeTokensHashed(Company $company)
|
||||
{
|
||||
$transformer = new CompanyTokenHashedTransformer($this->serializer);
|
||||
|
@ -80,7 +80,6 @@
|
||||
|
||||
@endsection
|
||||
|
||||
|
||||
@push('footer')
|
||||
|
||||
<script>
|
||||
|
Loading…
Reference in New Issue
Block a user