File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ abstract class Filter implements JsonSerializable
2222
2323 public string $ type = 'value ' ;
2424
25- public string $ title ;
25+ public ? string $ title = null ;
2626
2727 public string $ description = '' ;
2828
@@ -92,6 +92,14 @@ protected function getType(): string
9292
9393 protected function title (): string
9494 {
95+ if ($ this ->title ) {
96+ return $ this ->title ;
97+ }
98+
99+ if ($ column = $ this ->column ()) {
100+ return Str::title (Str::snake (Str::studly ($ column ), ' ' ));
101+ }
102+
95103 return $ this ->title ?? Str::title (Str::snake (class_basename (static ::class), ' ' ));
96104 }
97105
Original file line number Diff line number Diff line change @@ -11,16 +11,16 @@ class MatchableFilterTest extends IntegrationTest
1111 public function test_matchable_filter_has_key (): void
1212 {
1313 $ filter = new class extends MatchFilter {
14- public ?string $ column = 'status ' ;
14+ public ?string $ column = 'approved_at ' ;
1515 };
1616
1717 tap (
1818 AssertableJson::fromArray ($ filter ->jsonSerialize ()),
1919 function (AssertableJson $ json ) {
2020 $ json
21- ->dump ()
2221 ->where ('key ' , 'matches ' )
23- ->where ('column ' , 'status ' )
22+ ->where ('title ' , 'Approved At ' )
23+ ->where ('column ' , 'approved_at ' )
2424 ;
2525 }
2626 );
You can’t perform that action at this time.
0 commit comments