37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Domains\Integration\Services;
|
|
|
|
use App\Domains\Integration\Models\Integration;
|
|
use App\Domains\Integration\Models\TenantIntegration;
|
|
|
|
class TenantIntegrationService
|
|
{
|
|
public function getTenantIntegration(string $tenantCode, string $integrationCode): ?TenantIntegration
|
|
{
|
|
return TenantIntegration::where('tenant_code', $tenantCode)
|
|
->where('integration_code', $integrationCode)
|
|
->first();
|
|
}
|
|
|
|
public function getAllForTenant(string $tenantCode)
|
|
{
|
|
return TenantIntegration::with('integration')
|
|
->where('tenant_code', $tenantCode)
|
|
->get();
|
|
}
|
|
|
|
public function updateOrCreateIntegration(string $tenantCode, Integration $integration, array $data): TenantIntegration
|
|
{
|
|
return TenantIntegration::updateOrCreate(
|
|
[
|
|
'tenant_code' => $tenantCode,
|
|
'integration_code' => $integration->integration_code,
|
|
],
|
|
[
|
|
'integration_data' => $data,
|
|
]
|
|
);
|
|
}
|
|
}
|