@php // Get accounts from user if not provided if (!isset($accounts)) { $accounts = $user->accounts; } // Ensure accounts is a collection if (!($accounts instanceof \Illuminate\Support\Collection)) { $accounts = collect($accounts); } $account = $accounts->first(); $allSameModel = $user->hasDifferentDomophoneModels(); $hasRegularGsmDomophoneEntrance = $user->has_regular_gsm_domophone_entrance; // Process assigned codes for each account if ($account) { for ($index = 1; $index <= 20; $index++) { $account->{'assignedCode_' . $index} = null; if ($hasRegularGsmDomophoneEntrance) { $assignedCode = \Illuminate\Support\Facades\DB::table('user_phone_codes') ->where('user_id', $user->id) ->where('phone', $account->{'account_' . $index}) ->first(); if ($assignedCode) { $account->{'assignedCode_' . $index} = $assignedCode->code; } } } } // If no accounts exist, create an empty account object for the form if ($accounts->isEmpty()) { $account = new \App\Models\UserAccount(); $accounts = collect([$account]); } // Set default title if not provided if (!isset($title)) { $title = $user->name . ' ოჯახის წევრები'; } // Set default back route if not provided if (!isset($backRoute)) { $backRoute = route('users.index'); } // Calculate initial visible inputs (minimum 5, or more if accounts exist) $initialVisibleInputs = 5; if ($account) { for ($i = 6; $i <= 20; $i++) { if (!empty($account->{'account_' . $i})) { $initialVisibleInputs = $i; } } } @endphp

{{ $title }}

@can('users.accountsAdd') @csrf @endcan
@foreach ($accounts as $account) @for ($i = 1; $i <= $initialVisibleInputs; $i++) @endfor @endforeach
@can('users.accountsAdd') @if (!$user->has_at_least_one_k6_domophone)
@endif @endcan
@can('users.accountsAdd') @endcan უკან
@push('scripts') @endpush