@extends('layouts.app') @section('title', 'التكاملات') @php /** @var \Illuminate\Support\Collection $integrations */ /** @var array $schema */ /** @var array $available */ /** @var string|null $emptyReason */ $secretMask = '••••••••'; $clinicCountry = optional(app(\App\Services\TenantManager::class)->current())->country; $countryLabel = [ 'SA' => '🇸🇦 السعودية', 'EG' => '🇪🇬 مصر', 'AE' => '🇦🇪 الإمارات', 'US' => '🇺🇸 الولايات المتحدة', ][strtoupper((string) $clinicCountry)] ?? $clinicCountry; @endphp @section('content') @if(empty($available))

لا يوجد تكامل متاح

{{ $emptyReason ?? 'لا يوجد تكامل متاح في باقتك الحالية.' }}

@endif
@foreach($available as $provider) @php $meta = $schema[$provider]; $integration = $integrations->get($provider); // The DB row is seeded by IntegrationSeeder; if missing (older tenant // that never got the seed) we treat it as a fresh row in-memory so // the form still renders — the controller will create on save. if (! $integration) { $integration = new \App\Models\Tenant\Integration([ 'provider' => $provider, 'name' => $meta['label'], 'environment' => \App\Models\Tenant\Integration::ENV_SANDBOX, 'is_enabled' => false, ]); } $creds = $integration->credentials ?? []; @endphp
@csrf

{{ $meta['label'] }}

{{ $meta['description'] }}
@if($integration->last_status) {{ $integration->last_status === 'success' ? 'آخر فحص ناجح' : 'فشل آخر فحص' }} @if($integration->last_sync_at) — {{ $integration->last_sync_at->diffForHumans() }} @endif @endif
@if($integration->last_error && $integration->last_status === 'failed')
آخر خطأ: {{ $integration->last_error }}
@endif
ابدأ بالـ Sandbox دائمًا حتى تتأكد من البيانات.
@if($meta['docs_url']) @endif

بيانات الاعتماد

@foreach($meta['fields'] as $key => $field) @php $hasValue = isset($creds[$key]) && $creds[$key] !== ''; $isSecret = ! empty($field['secret']); $shownValue = $isSecret && $hasValue ? '' : ($creds[$key] ?? ''); $colClass = ($field['type'] ?? 'text') === 'textarea' ? 'col-12' : 'col-md-6'; @endphp
@if(($field['type'] ?? 'text') === 'textarea') @else @endif @if(! empty($field['help'])) {{ $field['help'] }} @endif @if($isSecret && $hasValue) محفوظ — اتركه فارغًا للإبقاء عليه. @endif
@endforeach
@endforeach
@endsection @push('scripts') @endpush