From 06382aed018dad9074dfcc1709863af4b1863521 Mon Sep 17 00:00:00 2001 From: Ahmed Darrazi Date: Sat, 13 Dec 2025 22:56:45 +0100 Subject: [PATCH] Fix: Address 'Too few arguments' error in settings catalog view --- .../settings-catalog-grouped.blade.php | 160 ++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 resources/views/filament/infolists/entries/settings-catalog-grouped.blade.php diff --git a/resources/views/filament/infolists/entries/settings-catalog-grouped.blade.php b/resources/views/filament/infolists/entries/settings-catalog-grouped.blade.php new file mode 100644 index 0000000..1be2232 --- /dev/null +++ b/resources/views/filament/infolists/entries/settings-catalog-grouped.blade.php @@ -0,0 +1,160 @@ +@php + use Illuminate\Support\Str; + use function Filament\Support\evaluate; + + // Normalize incoming state from Filament ViewEntry. Accept multiple shapes: + // - $groups passed directly + // - $state as array with ['groups' => [...]] + // - $state as JSON string + // - $state as a Closure + $groups = []; + $searchQuery = $searchQuery ?? ''; + + // If $state is a closure, resolve it first. + $state = evaluate($state); + + if (isset($groups) && is_array($groups) && count($groups) > 0) { + // $groups already provided by caller + // leave as-is + } elseif (isset($state)) { + if (is_string($state) && Str::startsWith(trim($state), '{')) { + $decoded = json_decode($state, true); + if (is_array($decoded)) { + $groups = $decoded['groups'] ?? $decoded; + } + } elseif (is_array($state)) { + $groups = $state['groups'] ?? $state; + } elseif (is_object($state)) { + $arr = (array) $state; + $groups = $arr['groups'] ?? $arr; + } + } + + // Ensure groups is an array + if (! is_array($groups)) { + $groups = []; + } +@endphp + +
+ @if(empty($groups)) +
+

No settings available

+
+ @else + @foreach($groups as $groupIndex => $group) + @php + // Filter settings by search query + $filteredSettings = collect($group['settings'] ?? [])->filter(function($setting) use ($searchQuery) { + if (empty($searchQuery)) { + return true; + } + + $searchLower = strtolower($searchQuery); + return str_contains(strtolower($setting['label'] ?? ''), $searchLower) || + str_contains(strtolower($setting['value_display'] ?? ''), $searchLower); + })->all(); + + $settingCount = count($filteredSettings); + @endphp + + @if($settingCount > 0) + + + + {{ $settingCount }} {{ Str::plural('setting', $settingCount) }} + + + +
+ @foreach($filteredSettings as $setting) +
+
+
+ + {{ $setting['label'] }} + + + @if($setting['is_fallback'] ?? false) + + Definition not cached + + @endif +
+ + @if(!empty($setting['help_text'])) +

+ {{ Str::limit($setting['help_text'], 200) }} +

+ @endif +
+ +
+
+ @if(is_bool($setting['value_raw'])) + + {{ $setting['value_display'] }} + + @elseif(is_int($setting['value_raw'])) + + {{ $setting['value_display'] }} + + @else + + {{ $setting['value_display'] }} + + @endif +
+ + @if(strlen($setting['value_display'] ?? '') > 50) + + @endif +
+
+ @endforeach +
+
+ @endif + @endforeach + + @if(collect($groups)->sum(fn($g) => count(collect($g['settings'] ?? [])->filter(function($s) use ($searchQuery) { + if (empty($searchQuery)) return true; + $searchLower = strtolower($searchQuery); + return str_contains(strtolower($s['label'] ?? ''), $searchLower) || + str_contains(strtolower($s['value_display'] ?? ''), $searchLower); + }))) === 0) +
+

No settings match your search

+ +
+ @endif + @endif +