Skip to content

Commit 228e7ed

Browse files
authored
Update creating-columns.md
Update code example and consistency
1 parent ee303cd commit 228e7ed

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

docs/columns/creating-columns.md

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ The `columns` method on your component must return an array of Column objects in
88
```php
99
public function columns(): array
1010
{
11-
Column::make('Name'),
12-
Column::make('Email'),
11+
return [
12+
Column::make('Name'),
13+
Column::make('Email'),
14+
];
1315
}
1416
```
1517

@@ -20,13 +22,23 @@ By default, you only need one parameter which acts as the header of the column,
2022
So if you have:
2123

2224
```php
23-
Column::make('Name') // Looks for column `name`
24-
Column::make('Email') // Looks for column `email`
25+
public function columns(): array
26+
{
27+
return [
28+
Column::make('Name') // Looks for column `name`
29+
Column::make('Email') // Looks for column `email`
30+
];
31+
}
2532
```
2633

2734
Of course, this won't work in every situation, for example if you have an ID column, Str::snake will convert it to `i_d` which is incorrect. For this situation and any other situation where you want to specify the field name, you can pass it as the second parameter:
2835

2936
```php
30-
Column::make('ID', 'id'),
31-
Column::make('E-mail', 'email'),
37+
public function columns(): array
38+
{
39+
return [
40+
Column::make('ID', 'id'),
41+
Column::make('E-mail', 'email'),
42+
];
43+
}
3244
```

0 commit comments

Comments
 (0)