11@php
2- $flags = $getState (); // Example: More than 4 flags
2+ $flags = $getState ();
33 $visibleFlags = [];
44 $remainingFlags = 0 ;
55 $currentLang = $this -> lang ?? request ()-> get (' lang' , app ()-> getLocale ());
99 $currentLangFlag = null ;
1010 $otherFlags = [];
1111
12- foreach ($flags as $flag ) {
13- $flagLang = str_replace (' flag-' , ' ' , str_replace (' trashed' , ' ' , $flag ));
14- if ($flagLang === $currentLang ) {
12+ foreach ($flags as $flagData ) {
13+ $flag = $flagData [' flag' ];
14+ $locale = $flagData [' locale' ];
15+
16+ if ($locale === $currentLang ) {
1517 $currentLangFlag = $flag ;
1618 } else {
1719 $otherFlags [] = $flag ;
2325 $otherVisibleFlags = array_slice ($otherFlags , 0 , 2 );
2426 $visibleFlags = array_merge ($visibleFlags , $otherVisibleFlags );
2527 } else {
26- $visibleFlags = array_slice ($flags , 0 , 3 );
28+ $visibleFlags = array_slice (array_column ( $flags , ' flag ' ) , 0 , 3 );
2729 }
2830
2931 $remainingFlags = max (0 , count ($flags ) - count ($visibleFlags ));
3234 $visibleFlags = [];
3335 $remainingFlags = 0 ;
3436 }
35- $visibleFlags = array_reverse ($visibleFlags );
3637@endphp
3738<x-filament-forms::field-wrapper >
3839 <div style =" padding-left : 30% ; position : relative ; height : 28px ; min-width : 66px ;" >
3940 <div style =" position : relative ; height : 28px ; min-width : 66px ;" >
40- @foreach ($visibleFlags as $revIndex => $flag )
41- @php
42- $index = count ($visibleFlags ) - 1 - $revIndex ;
43- $isTrashed = str_contains ($flag , ' trashed' );
44- $flagComponent = str_replace (' trashed' , ' ' , $flag );
45- @endphp
46- <span style =" position : absolute ; left : {{ $index * 18 }}px ; z-index : {{ 10 + $index }};" >
47- <x-dynamic-component :component =" $flagComponent"
48- style =" width : 24px ; height : 24px ; border-radius : 50% ; background : #fff ;" />
49- </span >
41+ @foreach ($visibleFlags as $index => $flag )
42+ @php
43+ $isTrashed = str_contains ($flag , ' trashed' );
44+ $flagComponent = str_replace (' trashed' , ' ' , $flag );
45+ @endphp
46+ <span style =" position : absolute ; left : {{ $index * 18 }}px ; z-index : {{ 10 + $index }};" >
47+ <x-dynamic-component :component =" $flagComponent"
48+ style =" width : 24px ; height : 24px ; border-radius : 50% ; background : #fff ;" />
49+ </span >
5050 @endforeach
51- @if ($remainingFlags > 0 )
52- <span style =" position : absolute ; left : {{ (count($visibleFlags) * 18) + 8 }}px ; z-index : 20 ;" >
53- <div
54- class =" flex items-center justify-center w-6 h-6 text-sm font-bold text-black rounded-full bg-white border border-gray-300" >
55- +{{ $remainingFlags } }
56- </div >
57- </span >
58- @endif
51+ @if ($remainingFlags > 0 )
52+ <span style =" position : absolute ; left : {{ (count($visibleFlags) * 18) + 8 }}px ; z-index : 20 ;" >
53+ <div class =" flex items-center justify-center w-6 h-6 text-sm font-bold text-black rounded-full bg-white border border-gray-300" >
54+ +{{ $remainingFlags } }
55+ </div >
56+ </span >
57+ @endif
5958 </div >
6059 </div >
6160</x-filament-forms::field-wrapper >
0 commit comments