File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
tests/Views/Traits/Helpers Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,10 @@ public function validate($value)
43
43
44
44
public function getFilterPillValue ($ value ): ?string
45
45
{
46
- return $ this ->getCustomFilterPillValue ($ value ) ?? $ this ->getOptions ()[$ value ] ?? null ;
46
+ return $ this ->getCustomFilterPillValue ($ value )
47
+ ?? collect ($ this ->getOptions ())
48
+ ->mapWithKeys (fn ($ options , $ optgroupLabel ) => is_iterable ($ options ) ? $ options : [$ optgroupLabel => $ options ])[$ value ]
49
+ ?? null ;
47
50
}
48
51
49
52
public function isEmpty ($ value ): bool
Original file line number Diff line number Diff line change @@ -130,6 +130,21 @@ public function can_get_filter_pill_value(): void
130
130
$ this ->assertSame ('baz ' , $ filter ->getFilterPillValue ('foo ' ));
131
131
}
132
132
133
+ /** @test */
134
+ public function can_get_nested_filter_pill_value (): void
135
+ {
136
+ $ filter = SelectFilter::make ('Active ' )
137
+ ->options (['foo ' => ['bar ' => 'baz ' ]]);
138
+
139
+ $ this ->assertSame ('baz ' , $ filter ->getFilterPillValue ('bar ' ));
140
+
141
+ $ filter = SelectFilter::make ('Active ' )
142
+ ->options (['foo ' => ['bar ' => 'baz ' ]])
143
+ ->setFilterPillValues (['bar ' => 'etc ' ]);
144
+
145
+ $ this ->assertSame ('etc ' , $ filter ->getFilterPillValue ('bar ' ));
146
+ }
147
+
133
148
/** @test */
134
149
public function can_check_if_filter_has_configs (): void
135
150
{
You can’t perform that action at this time.
0 commit comments