File tree Expand file tree Collapse file tree 3 files changed +65
-1
lines changed
Expand file tree Collapse file tree 3 files changed +65
-1
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,10 @@ class ArrayColumn extends Column
2424
2525 protected mixed $ outputFormat = null ;
2626
27+ public ?string $ outputWrapperStart = null ;
28+
29+ public ?string $ outputWrapperEnd = null ;
30+
2731 public function __construct (string $ title , ?string $ from = null )
2832 {
2933 parent ::__construct ($ title , $ from );
@@ -49,6 +53,12 @@ public function getContents(Model $row): null|string|\BackedEnum|HtmlString|Data
4953 $ outputValues [] = call_user_func ($ this ->getOutputFormatCallback (), $ i , $ v );
5054 }
5155
52- return new HtmlString ((! empty ($ outputValues ) ? implode ($ this ->getSeparator (), $ outputValues ) : $ this ->getEmptyValue ()));
56+ $ returnedValue = (! empty ($ outputValues ) ? implode ($ this ->getSeparator (), $ outputValues ) : $ this ->getEmptyValue ());
57+
58+ if ($ this ->hasOutputWrapperStart () && $ this ->hasOutputWrapperEnd ())
59+ {
60+ $ returnedValue = $ this ->getOutputWrapperStart () . $ returnedValue . $ this ->getOutputWrapperEnd ();
61+ }
62+ return new HtmlString ($ returnedValue );
5363 }
5464}
Original file line number Diff line number Diff line change @@ -34,4 +34,36 @@ public function emptyValue(string $emptyValue): self
3434
3535 return $ this ;
3636 }
37+
38+
39+ public function wrapperStart (string $ value ): self
40+ {
41+ $ this ->outputWrapperStart = $ value ;
42+
43+ return $ this ;
44+ }
45+
46+ public function wrapperEnd (string $ value ): self
47+ {
48+ $ this ->outputWrapperEnd = $ value ;
49+
50+ return $ this ;
51+ }
52+
53+ public function flexCol (array $ attribs = []): self
54+ {
55+ $ bag = new ComponentAttributeBag (['class ' => $ this ->isTailwind () ? 'flex flex-col ' : 'd-flex d-flex-col ' ]);
56+
57+ return $ this ->wrapperStart ('<div ' .$ bag ->merge ($ attribs ).'> ' )
58+ ->wrapperEnd ('</div> ' );
59+ }
60+
61+ public function flexRow (array $ attribs = []): self
62+ {
63+ $ bag = new ComponentAttributeBag (['class ' => $ this ->isTailwind () ? 'flex flex-row ' : 'd-flex d-flex-row ' ]);
64+
65+ return $ this ->wrapperStart ('<div ' .$ bag ->merge ($ attribs ).'> ' )
66+ ->wrapperEnd ('</div> ' );
67+ }
68+
3769}
Original file line number Diff line number Diff line change @@ -38,4 +38,26 @@ public function getOutputFormatCallback(): ?callable
3838 {
3939 return $ this ->outputFormat ;
4040 }
41+
42+
43+
44+ public function hasOutputWrapperStart (): bool
45+ {
46+ return $ this ->outputWrapperStart !== null && is_string ($ this ->outputWrapperStart );
47+ }
48+
49+ public function getOutputWrapperStart (): string
50+ {
51+ return $ this ->outputWrapperStart ;
52+ }
53+
54+ public function hasOutputWrapperEnd (): bool
55+ {
56+ return $ this ->outputWrapperEnd !== null && is_string ($ this ->outputWrapperEnd );
57+ }
58+
59+ public function getOutputWrapperEnd (): string
60+ {
61+ return $ this ->outputWrapperEnd ;
62+ }
4163}
You can’t perform that action at this time.
0 commit comments