@if ($gedung[0]->nama_gedung == 'Central')

POS SECURITY

{{--
S01C
S01E
S01K
S01H
S01I
S01J
--}} {{--
@php $s01a_pintu = $semua_pintu->filter(function ($pintu) { return str_starts_with($pintu->kodepintu, 'S01A'); }); $first_pintu = $s01a_pintu->first(); @endphp @if ($first_pintu) @if (isset($loker_info[$first_pintu->kodepintu]))
S01A
@else
S01A
@endif @else
S01A
@endif
--}} {{--
S01M
S01G
S01F
S01N
S01L
S01O
S01P
S01B
S01D
S01Q
--}} {{--

Jendela

--}} {{--

18 loker isi 9 pintu

--}} {{--
--}} {{--
S01R
S01S
S01T
S01U
S02F
S01V
S01W
S02G
S02E
S02D
S02B
S01Y
S02J
S02H
S02I
S02C
S02A
S01X
S01Z
S02P
S02Q
S02R
S02L
S02M
S02K
S02N
S02O
{{--

8 loker isi 15 pintu

--}} {{--
--}} {{--

TANGGA PARKIRAN

--}} {{--
--}} {{-- dibawah ini untuk ngambil peminjam loker menggunakan loop foreach dari database --}}
{{-- Kolom 1 --}}
@foreach (['S01C', 'S01E', 'S01K', 'S01H', 'S01I', 'S01J'] as $kode) @php $filtered_pintu = $semua_pintu->filter(function ($pintu) use ($kode) { return str_starts_with($pintu->kodepintu, $kode); }); $first_pintu = $filtered_pintu->first(); $has_borrower = $first_pintu && isset($loker_info[$first_pintu->kodepintu]) && !empty($loker_info[$first_pintu->kodepintu]); $tooltip_content = ''; if ($has_borrower) { $names = $loker_info[$first_pintu->kodepintu]; if (is_array($names)) { $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . $name; }, $names); $tooltip_content = implode('
', $formatted_names); } else { $tooltip_content = str_replace( "\n", '
' . $first_pintu->kodepintu . ' - ', $first_pintu->kodepintu . ' - ' . $names, ); } } @endphp
{{ $kode }}
@endforeach
{{-- kolom 2 --}}
@php $kode = 'S01A'; $filtered_pintu = $semua_pintu->filter(function ($pintu) use ($kode) { return str_starts_with($pintu->kodepintu, $kode); }); $first_pintu = $filtered_pintu->first(); $has_borrower = $first_pintu && isset($loker_info[$first_pintu->kodepintu]) && !empty($loker_info[$first_pintu->kodepintu]); $tooltip_content = ''; if ($has_borrower) { $names = $loker_info[$first_pintu->kodepintu]; if (is_array($names)) { // Jika array $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . $name; }, $names); $tooltip_content = implode('
', $formatted_names); } else { // Jika string dengan \n $tooltip_content = str_replace( "\n", '
' . $first_pintu->kodepintu . ' - ', $first_pintu->kodepintu . ' - ' . $names, ); } } @endphp
{{ $kode }}
{{-- Kolom 3 --}}
@foreach (['S01M', 'S01G'] as $kode) @php $filtered_pintu = $semua_pintu->filter(function ($pintu) use ($kode) { return str_starts_with($pintu->kodepintu, $kode); }); $first_pintu = $filtered_pintu->first(); $has_borrower = $first_pintu && isset($loker_info[$first_pintu->kodepintu]) && !empty($loker_info[$first_pintu->kodepintu]); $tooltip_content = ''; if ($has_borrower) { $names = $loker_info[$first_pintu->kodepintu]; if (is_array($names)) { $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . $name; }, $names); $tooltip_content = implode('
', $formatted_names); } else { $tooltip_content = str_replace( "\n", '
' . $first_pintu->kodepintu . ' - ', $first_pintu->kodepintu . ' - ' . $names, ); } } @endphp
{{ $kode }}
@endforeach
@foreach (['S01F', 'S01N'] as $kode) @php $filtered_pintu = $semua_pintu->filter(function ($pintu) use ($kode) { return str_starts_with($pintu->kodepintu, $kode); }); $first_pintu = $filtered_pintu->first(); $has_borrower = $first_pintu && isset($loker_info[$first_pintu->kodepintu]) && !empty($loker_info[$first_pintu->kodepintu]); $tooltip_content = ''; if ($has_borrower) { $names = $loker_info[$first_pintu->kodepintu]; if (is_array($names)) { $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . $name; }, $names); $tooltip_content = implode('
', $formatted_names); } else { $tooltip_content = str_replace( "\n", '
' . $first_pintu->kodepintu . ' - ', $first_pintu->kodepintu . ' - ' . $names, ); } } @endphp
{{ $kode }}
@endforeach
{{-- Kolom 4 --}}
@foreach (['S01L', 'S01O', 'S01P'] as $kode) @php $filtered_pintu = $semua_pintu->filter(function ($pintu) use ($kode) { return str_starts_with($pintu->kodepintu, $kode); }); $first_pintu = $filtered_pintu->first(); $has_borrower = $first_pintu && isset($loker_info[$first_pintu->kodepintu]) && !empty($loker_info[$first_pintu->kodepintu]); $tooltip_content = ''; if ($has_borrower) { $names = $loker_info[$first_pintu->kodepintu]; if (is_array($names)) { $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . $name; }, $names); $tooltip_content = implode('
', $formatted_names); } else { $tooltip_content = str_replace( "\n", '
' . $first_pintu->kodepintu . ' - ', $first_pintu->kodepintu . ' - ' . $names, ); } } @endphp
{{ $kode }}
@endforeach
{{-- Kolom 5 --}}
@foreach (['S01B', 'S01D', 'S01Q'] as $kode) @php $filtered_pintu = $semua_pintu->filter(function ($pintu) use ($kode) { return str_starts_with($pintu->kodepintu, $kode); }); $first_pintu = $filtered_pintu->first(); $has_borrower = $first_pintu && isset($loker_info[$first_pintu->kodepintu]) && !empty($loker_info[$first_pintu->kodepintu]); $tooltip_content = ''; if ($has_borrower) { $names = $loker_info[$first_pintu->kodepintu]; if (is_array($names)) { $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . $name; }, $names); $tooltip_content = implode('
', $formatted_names); } else { $tooltip_content = str_replace( "\n", '
' . $first_pintu->kodepintu . ' - ', $first_pintu->kodepintu . ' - ' . $names, ); } } @endphp
{{ $kode }}
@endforeach
@foreach (['S01R', 'S01S', 'S01T', 'S01U', 'S02F', 'S01V', 'S01W'] as $kode) @php $filtered_pintu = $semua_pintu->filter(function ($pintu) use ($kode) { return str_starts_with($pintu->kodepintu, $kode); }); $first_pintu = $filtered_pintu->first(); $has_borrower = $first_pintu && isset($loker_info[$first_pintu->kodepintu]) && !empty($loker_info[$first_pintu->kodepintu]); $tooltip_content = ''; if ($has_borrower) { $names = $loker_info[$first_pintu->kodepintu]; if (is_array($names)) { $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . $name; }, $names); $tooltip_content = implode('
', $formatted_names); } else { $tooltip_content = str_replace( "\n", '
' . $first_pintu->kodepintu . ' - ', $first_pintu->kodepintu . ' - ' . $names, ); } } @endphp
{{ $kode }}
@endforeach
{{-- Kolom 2 --}}
@foreach (['S02G', 'S02E', 'S02D', 'S02B', 'S01Y'] as $kode) @php $filtered_pintu = $semua_pintu->filter(function ($pintu) use ($kode) { return str_starts_with($pintu->kodepintu, $kode); }); $first_pintu = $filtered_pintu->first(); $has_borrower = $first_pintu && isset($loker_info[$first_pintu->kodepintu]) && !empty($loker_info[$first_pintu->kodepintu]); $tooltip_content = ''; if ($has_borrower) { $names = $loker_info[$first_pintu->kodepintu]; if (is_array($names)) { $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . $name; }, $names); $tooltip_content = implode('
', $formatted_names); } else { $tooltip_content = str_replace( "\n", '
' . $first_pintu->kodepintu . ' - ', $first_pintu->kodepintu . ' - ' . $names, ); } } @endphp
{{ $kode }}
@endforeach
{{-- Kolom 3 --}}
@foreach (['S02J', 'S02H', 'S02I', 'S02C', 'S02A', 'S01X', 'S01Z'] as $kode) @php $filtered_pintu = $semua_pintu->filter(function ($pintu) use ($kode) { return str_starts_with($pintu->kodepintu, $kode); }); $first_pintu = $filtered_pintu->first(); $has_borrower = $first_pintu && isset($loker_info[$first_pintu->kodepintu]) && !empty($loker_info[$first_pintu->kodepintu]); $tooltip_content = ''; if ($has_borrower) { $names = $loker_info[$first_pintu->kodepintu]; if (is_array($names)) { $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . $name; }, $names); $tooltip_content = implode('
', $formatted_names); } else { $tooltip_content = str_replace( "\n", '
' . $first_pintu->kodepintu . ' - ', $first_pintu->kodepintu . ' - ' . $names, ); } } @endphp
{{ $kode }}
@endforeach
{{-- Kolom terakhir --}}
@php $codes = ['S02P', 'S02Q', 'S02R', 'S02L', 'S02M', 'S02K', 'S02N', 'S02O']; @endphp @foreach ($codes as $code) @php $filtered_pintu = $semua_pintu->filter(function ($pintu) use ($code) { return str_starts_with($pintu->kodepintu, $code); }); $first_pintu = $filtered_pintu->first(); $has_borrower = $first_pintu && isset($loker_info[$first_pintu->kodepintu]) && !empty($loker_info[$first_pintu->kodepintu]); $tooltip_content = ''; if ($has_borrower) { $names = $loker_info[$first_pintu->kodepintu]; if (is_array($names)) { $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . $name; }, $names); $tooltip_content = implode('
', $formatted_names); } else { $tooltip_content = str_replace( "\n", '
' . $first_pintu->kodepintu . ' - ', $first_pintu->kodepintu . ' - ' . $names, ); } } @endphp
{{ $code }}
@endforeach
@elseif($gedung[0]->nama_gedung == 'Gedung A')

APD GBJ

{{-- kurang benahin ini --}}
{{--
A01K
A01L
--}} @foreach (['A01K', 'A01L'] as $kode) @php $filtered_pintu = $semua_pintu->filter(function ($pintu) use ($kode) { return str_starts_with($pintu->kodepintu, $kode); }); $first_pintu = $filtered_pintu->first(); $has_borrower = $first_pintu && isset($loker_info[$first_pintu->kodepintu]) && !empty($loker_info[$first_pintu->kodepintu]); $tooltip_content = ''; if ($has_borrower) { $names = $loker_info[$first_pintu->kodepintu]; if (is_array($names)) { $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . $name; }, $names); $tooltip_content = implode('
', $formatted_names); } else { $lines = explode("\n", $names); $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . trim($name); }, $lines); $tooltip_content = implode('
', $formatted_names); } } @endphp @if ($kode === 'A01K')
{{ $kode }}
@endif @if ($kode === 'A01L')
{{ $kode }}
@endif @endforeach

APD Gedung A

{{--
A01B
A01F
A01E
A01D
A01H
A01C
A01G
A01A
--}} @foreach (['A01B', 'A01F', 'A01E', 'A01D', 'A01H', 'A01C', 'A01G', 'A01A'] as $kode) @php $filtered_pintu = $semua_pintu->filter(function ($pintu) use ($kode) { return str_starts_with($pintu->kodepintu, $kode); }); $first_pintu = $filtered_pintu->first(); $has_borrower = $first_pintu && isset($loker_info[$first_pintu->kodepintu]) && !empty($loker_info[$first_pintu->kodepintu]); // Prepare tooltip content $tooltip_content = ''; if ($has_borrower) { $names = $loker_info[$first_pintu->kodepintu]; if (is_array($names)) { // Jika array $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . $name; }, $names); $tooltip_content = implode('
', $formatted_names); } else { // Jika string dengan \n $tooltip_content = str_replace( "\n", '
' . $first_pintu->kodepintu . ' - ', $first_pintu->kodepintu . ' - ' . $names, ); } } @endphp
{{ $kode }}
@endforeach
{{--
PU
--}} @foreach (['PU'] as $kode) @php $filtered_pintu = $semua_pintu->filter(function ($pintu) use ($kode) { return str_starts_with($pintu->kodepintu, $kode); }); $first_pintu = $filtered_pintu->first(); $has_borrower = $first_pintu && isset($loker_info[$first_pintu->kodepintu]) && !empty($loker_info[$first_pintu->kodepintu]); $tooltip_content = ''; if ($has_borrower) { $names = $loker_info[$first_pintu->kodepintu]; if (is_array($names)) { $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . $name; }, $names); $tooltip_content = implode('
', $formatted_names); } else { $tooltip_content = str_replace( "\n", '
' . $first_pintu->kodepintu . ' - ', $first_pintu->kodepintu . ' - ' . $names, ); } } @endphp
{{ $kode }}
@endforeach
@elseif($gedung[0]->nama_gedung == 'Gedung B')

APD Gedung B

{{--
B01F
B01E
B01D
B01C
B01B
B01A
--}}
@foreach (['B01F', 'B01E', 'B01D', 'B01C', 'B01B', 'B01A'] as $kode)
@php $filtered_pintu = $semua_pintu->filter(function ($pintu) use ($kode) { return str_starts_with($pintu->kodepintu, $kode); }); $first_pintu = $filtered_pintu->first(); $has_borrower = $first_pintu && isset($loker_info[$first_pintu->kodepintu]) && !empty($loker_info[$first_pintu->kodepintu]); $tooltip_content = ''; if ($has_borrower) { $names = $loker_info[$first_pintu->kodepintu]; if (is_array($names)) { $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . $name; }, $names); $tooltip_content = implode('
', $formatted_names); } else { $tooltip_content = str_replace( "\n", '
' . $first_pintu->kodepintu . ' - ', $first_pintu->kodepintu . ' - ' . $names, ); } } @endphp
{{ $kode }}
@endforeach
JALUR PEJALAN KAKI
@elseif($gedung[0]->nama_gedung == 'Gedung C')

APD Gedung C

{{--
PINTU
C01G
C01F
--}}
PINTU
@foreach (['C01G', 'C01F'] as $index => $kode) @php $filtered_pintu = $semua_pintu->filter(function ($pintu) use ($kode) { return str_starts_with($pintu->kodepintu, $kode); }); $first_pintu = $filtered_pintu->first(); $has_borrower = $first_pintu && isset($loker_info[$first_pintu->kodepintu]) && !empty($loker_info[$first_pintu->kodepintu]); $tooltip_content = ''; if ($has_borrower) { $names = $loker_info[$first_pintu->kodepintu]; if (is_array($names)) { $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . $name; }, $names); $tooltip_content = implode('
', $formatted_names); } else { $tooltip_content = str_replace( "\n", '
' . $first_pintu->kodepintu . ' - ', $first_pintu->kodepintu . ' - ' . $names, ); } } @endphp
{{ $kode }}
@endforeach
{{--
C01A
C01B
C01C
C01D
C01E
--}} @foreach (['C01A', 'C01B', 'C01C', 'C01D', 'C01E'] as $kode)
@php $filtered_pintu = $semua_pintu->filter(function ($pintu) use ($kode) { return str_starts_with($pintu->kodepintu, $kode); }); $first_pintu = $filtered_pintu->first(); $has_borrower = $first_pintu && isset($loker_info[$first_pintu->kodepintu]) && !empty($loker_info[$first_pintu->kodepintu]); $tooltip_content = ''; if ($has_borrower) { $names = $loker_info[$first_pintu->kodepintu]; if (is_array($names)) { $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . $name; }, $names); $tooltip_content = implode('
', $formatted_names); } else { $tooltip_content = str_replace( "\n", '
' . $first_pintu->kodepintu . ' - ', $first_pintu->kodepintu . ' - ' . $names, ); } } @endphp
{{ $kode }}
@endforeach {{-- @foreach (['C01A', 'C01B', 'C01C', 'C01D', 'C01E'] as $kode)
@php $filtered_pintu = $semua_pintu->filter(function ($pintu) use ($kode) { return str_starts_with($pintu->kodepintu, $kode); }); // Get the first door in the filtered list $first_pintu = $filtered_pintu->first(); // Cek apakah ada data peminjam $has_borrower = $first_pintu && isset($loker_info[$first_pintu->kodepintu]) && !empty($loker_info[$first_pintu->kodepintu]); // Prepare tooltip content $tooltip_content = ''; if ($has_borrower) { $names = $loker_info[$first_pintu->kodepintu]; if (is_array($names)) { $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . $name; }, $names); $tooltip_content = implode('
', $formatted_names); } else { // Jika string dengan \n $tooltip_content = str_replace( "\n", '
' . $first_pintu->kodepintu . ' - ', $first_pintu->kodepintu . ' - ' . $names, ); } } @endphp
@endforeach --}} {{--
C01E
--}}
@elseif($gedung[0]->nama_gedung == 'Gedung E')

APD Gedung E

{{--
PINTU
--}}
@foreach (['PINTU'] as $kode) @php $filtered_pintu = $semua_pintu->filter(function ($pintu) use ($kode) { return str_starts_with($pintu->kodepintu, $kode); }); $first_pintu = $filtered_pintu->first(); $has_borrower = $first_pintu && isset($loker_info[$first_pintu->kodepintu]) && !empty($loker_info[$first_pintu->kodepintu]); $tooltip_content = ''; if ($has_borrower) { $names = $loker_info[$first_pintu->kodepintu]; if (is_array($names)) { $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . $name; }, $names); $tooltip_content = implode('
', $formatted_names); } else { $tooltip_content = str_replace( "\n", '
' . $first_pintu->kodepintu . ' - ', $first_pintu->kodepintu . ' - ' . $names, ); } } @endphp
{{ $kode }}
@endforeach
{{--
E01A
E01B
--}}
@foreach (['E01A', 'E01B'] as $kode) @php $filtered_pintu = $semua_pintu->filter(function ($pintu) use ($kode) { return str_starts_with($pintu->kodepintu, $kode); }); $first_pintu = $filtered_pintu->first(); $has_borrower = $first_pintu && isset($loker_info[$first_pintu->kodepintu]) && !empty($loker_info[$first_pintu->kodepintu]); $tooltip_content = ''; if ($has_borrower) { $names = $loker_info[$first_pintu->kodepintu]; if (is_array($names)) { $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . $name; }, $names); $tooltip_content = implode('
', $formatted_names); } else { $tooltip_content = str_replace( "\n", '
' . $first_pintu->kodepintu . ' - ', $first_pintu->kodepintu . ' - ' . $names, ); } } @endphp
{{ $kode }}
@endforeach
{{--
E01D
E01C
--}}
@foreach (['E01D', 'E01C'] as $kode) @php $filtered_pintu = $semua_pintu->filter(function ($pintu) use ($kode) { return str_starts_with($pintu->kodepintu, $kode); }); $first_pintu = $filtered_pintu->first(); $has_borrower = $first_pintu && isset($loker_info[$first_pintu->kodepintu]) && !empty($loker_info[$first_pintu->kodepintu]); $tooltip_content = ''; if ($has_borrower) { $names = $loker_info[$first_pintu->kodepintu]; if (is_array($names)) { $formatted_names = array_map(function ($name) use ($first_pintu) { return $first_pintu->kodepintu . ' - ' . $name; }, $names); $tooltip_content = implode('
', $formatted_names); } else { $tooltip_content = str_replace( "\n", '
' . $first_pintu->kodepintu . ' - ', $first_pintu->kodepintu . ' - ' . $names, ); } } @endphp
{{ $kode }}
@endforeach
@else

tidak ada mappingnya

@endif {{-- saya looping menggunakan foreach dengan pola yang sama berikut hasil viewnya --}}