Skip to content

Commit 69f0b12

Browse files
authored
Add Docs
1 parent 5bc8866 commit 69f0b12

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

docs/column-types/array_column.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,64 @@ ArrayColumn::make('notes', 'name')
1313
->sortable(),
1414
```
1515

16-
### Empty Value
16+
## Empty Value
1717
You may define the default/empty value using the "emptyValue" method
1818

1919
```php
2020
ArrayColumn::make('notes', 'name')
2121
->emptyValue('Unknown'),
2222
```
2323

24+
## Wrapping the Output
25+
26+
As the ArrayColumn is designed to handle multiple related records, you can choose to wrap these for improved UX.
27+
28+
It is recommended that you utilise the built-in flexCol or flexRow approaches, which will also disable the separator
29+
30+
### flexCol
31+
This adds either:
32+
- Tailwind: 'flex flex-col'
33+
- Bootstrap: 'd-flex d-flex-col'
34+
35+
And merges any attributes specified in the sole parameter (as an array)
36+
```php
37+
ArrayColumn::make('notes', 'name')
38+
->data(fn($value, $row) => ($row->notes))
39+
->outputFormat(fn($index, $value) => "<a href='".$value->id."'>".$value->name."</a>")
40+
->flexCol(['class' => 'bg-red-500'])
41+
->sortable(),
42+
```
43+
44+
### flexRow
45+
46+
This adds either:
47+
- Tailwind: 'flex flex-row'
48+
- Bootstrap: 'd-flex d-flex-row'
49+
50+
And merges any attributes specified in the sole parameter (as an array)
51+
```php
52+
ArrayColumn::make('notes', 'name')
53+
->data(fn($value, $row) => ($row->notes))
54+
->outputFormat(fn($index, $value) => "<a href='".$value->id."'>".$value->name."</a>")
55+
->flexRow(['class' => 'bg-red-500'])
56+
->sortable(),
57+
```
58+
59+
### Manually
60+
61+
You can also specify a wrapperStart and wrapperEnd, for example, for an unordered list:
62+
63+
```php
64+
ArrayColumn::make('notes', 'name')
65+
->data(fn($value, $row) => ($row->notes))
66+
->outputFormat(fn($index, $value) => "<li><a href='".$value->id."'>".$value->name."</a></li>")
67+
->wrapperStart("<ul class='bg-blue'>")
68+
->wrapperEnd("</ul>")
69+
->sortable(),
70+
```
71+
72+
## See Also
73+
2474
Please also see the following for other available methods:
2575
<ul>
2676
<li>

0 commit comments

Comments
 (0)