@php $allSameModel = $user->hasDifferentDomophoneModels(); if (!isset($accounts)) { $accounts = $user->accounts; } if (!($accounts instanceof \Illuminate\Support\Collection)) { $accounts = collect($accounts); } $account = $accounts->first(); if (!$account) { $account = new \App\Models\UserAccount(); $accounts = collect([$account]); } $accountPhones = []; for ($i = 1; $i <= 20; $i++) { $phone = $account->{'account_' . $i} ?? null; if (!empty($phone)) { $accountPhones[] = preg_replace('/\s+/', '', trim($phone)); } } $storedBarrierPhones = $account->barrier_phones ?? []; $storedBarrierPhones = array_values(array_filter($storedBarrierPhones, fn($phone) => !empty($phone))); $barrierInputPhones = $storedBarrierPhones; $assignedCodesByPhone = \Illuminate\Support\Facades\DB::table('user_phone_codes') ->where('user_id', $user->id) ->get() ->mapWithKeys(function ($row) { $normalized = preg_replace('/\s+/', '', trim((string) $row->phone)); return [$normalized => $row->code]; }) ->toArray(); if (!isset($title)) { $title = $user->name . ' შლაგბაუმის ნომრები'; } if (!isset($backRoute)) { $backRoute = route('users.index'); } $initialVisibleInputs = max(5, count($barrierInputPhones)); $initialVisibleInputs = min(20, $initialVisibleInputs); @endphp