Skip to content

Commit 1dba550

Browse files
committed
UP
1 parent bab3745 commit 1dba550

File tree

2 files changed

+59
-16
lines changed

2 files changed

+59
-16
lines changed

src/Config/KanbanConfig.php

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,52 @@
1111
*
1212
* This class serves as the single source of truth for all Kanban board
1313
* configuration and prevents unintended configuration changes at runtime.
14+
*
15+
* @method self withColumnField(string $columnField) Set the field name that determines which column a card belongs to
16+
* @method self withColumnValues(array<string, string> $columnValues) Set the available column values with their labels
17+
* @method self withColumnColors(array<string, string>|null $columnColors) Set the color mappings for columns
18+
* @method self withTitleField(string $titleField) Set the field name used for card titles
19+
* @method self withDescriptionField(string|null $descriptionField) Set the field name for card descriptions
20+
* @method self withCardAttributes(array<string, string> $cardAttributes) Set the additional fields to display on cards
21+
* @method self withOrderField(string|null $orderField) Set the field name for maintaining card order
22+
* @method self withCardLabel(string|null $cardLabel) Set the label for individual cards
23+
* @method self withPluralCardLabel(string|null $pluralCardLabel) Set the plural label for collection of cards
24+
* @method self withCreateFormCallback(callable|null $createFormCallback) Set the callback for customizing the card creation form
1425
*/
15-
final class KanbanConfig
26+
final readonly class KanbanConfig
1627
{
1728
/**
1829
* Create a new Kanban configuration instance.
30+
*
31+
* @param string $columnField The field name that determines which column a card belongs to
32+
* @param array<string, string> $columnValues Available column values with their labels
33+
* @param array<string, string>|null $columnColors Optional color mappings for columns
34+
* @param string $titleField The field name used for card titles
35+
* @param string|null $descriptionField Optional field name for card descriptions
36+
* @param array<string, string> $cardAttributes Additional fields to display on cards
37+
* @param string|null $orderField Optional field name for maintaining card order
38+
* @param string|null $cardLabel Optional label for individual cards
39+
* @param string|null $pluralCardLabel Optional plural label for collection of cards
40+
* @param callable|null $createFormCallback Optional callback for customizing the card creation form
1941
*/
2042
public function __construct(
21-
private readonly string $columnField = 'status',
22-
private readonly array $columnValues = [],
23-
private readonly ?array $columnColors = null,
24-
private readonly string $titleField = 'title',
25-
private readonly ?string $descriptionField = null,
26-
private readonly array $cardAttributes = [],
27-
private readonly ?string $orderField = null,
28-
private readonly ?string $cardLabel = null,
29-
private readonly ?string $pluralCardLabel = null,
30-
private readonly mixed $createFormCallback = null,
43+
private string $columnField = 'status',
44+
private array $columnValues = [],
45+
private ?array $columnColors = null,
46+
private string $titleField = 'title',
47+
private ?string $descriptionField = null,
48+
private array $cardAttributes = [],
49+
private ?string $orderField = null,
50+
private ?string $cardLabel = null,
51+
private ?string $pluralCardLabel = null,
52+
private mixed $createFormCallback = null,
3153
) {
3254
}
3355

3456
/**
3557
* Get the field that stores the column value.
58+
*
59+
* @return string The column field name
3660
*/
3761
public function getColumnField(): string
3862
{
@@ -42,7 +66,7 @@ public function getColumnField(): string
4266
/**
4367
* Get the available column values with their labels.
4468
*
45-
* @return array<string, string>
69+
* @return array<string, string> Map of column values to their display labels
4670
*/
4771
public function getColumnValues(): array
4872
{
@@ -52,7 +76,7 @@ public function getColumnValues(): array
5276
/**
5377
* Get the colors for each column.
5478
*
55-
* @return array<string, string>|null
79+
* @return array<string, string>|null Map of column values to color codes, or null if not set
5680
*/
5781
public function getColumnColors(): ?array
5882
{
@@ -61,6 +85,8 @@ public function getColumnColors(): ?array
6185

6286
/**
6387
* Get the field used for card titles.
88+
*
89+
* @return string The title field name
6490
*/
6591
public function getTitleField(): string
6692
{
@@ -69,6 +95,8 @@ public function getTitleField(): string
6995

7096
/**
7197
* Get the field used for card descriptions.
98+
*
99+
* @return string|null The description field name, or null if not set
72100
*/
73101
public function getDescriptionField(): ?string
74102
{
@@ -78,7 +106,7 @@ public function getDescriptionField(): ?string
78106
/**
79107
* Get the additional fields to display on cards.
80108
*
81-
* @return array<string, string>
109+
* @return array<string, string> Map of attribute names to their display labels
82110
*/
83111
public function getCardAttributes(): array
84112
{
@@ -87,6 +115,8 @@ public function getCardAttributes(): array
87115

88116
/**
89117
* Get the field used for maintaining card order.
118+
*
119+
* @return string|null The order field name, or null if ordering is not enabled
90120
*/
91121
public function getOrderField(): ?string
92122
{
@@ -95,6 +125,8 @@ public function getOrderField(): ?string
95125

96126
/**
97127
* Get the label for individual cards.
128+
*
129+
* @return string|null The singular card label, or null to use default
98130
*/
99131
public function getCardLabel(): ?string
100132
{
@@ -103,6 +135,8 @@ public function getCardLabel(): ?string
103135

104136
/**
105137
* Get the plural label for collection of cards.
138+
*
139+
* @return string|null The plural card label, or null to use default
106140
*/
107141
public function getPluralCardLabel(): ?string
108142
{
@@ -111,6 +145,8 @@ public function getPluralCardLabel(): ?string
111145

112146
/**
113147
* Get the form callback for creating cards.
148+
*
149+
* @return mixed The form creation callback, or null if not set
114150
*/
115151
public function getCreateFormCallback(): mixed
116152
{
@@ -127,7 +163,7 @@ public function getCreateFormCallback(): mixed
127163
* @param string $method The method name
128164
* @param array $arguments The method arguments
129165
* @return self A new instance with the updated property
130-
* @throws \BadMethodCallException If the method is not a valid with* method
166+
* @throws \BadMethodCallException If the method is not a valid with* method or targets a non-existent property
131167
*/
132168
public function __call(string $method, array $arguments): self
133169
{
@@ -161,6 +197,11 @@ public function with(array $properties): self
161197
return new self(...$config);
162198
}
163199

200+
/**
201+
* Convert the configuration to an array.
202+
*
203+
* @return array<string, mixed> Array representation of the configuration
204+
*/
164205
public function toArray(): array
165206
{
166207
return [
@@ -176,4 +217,4 @@ public function toArray(): array
176217
'createFormCallback' => $this->createFormCallback,
177218
];
178219
}
179-
}
220+
}

src/Filament/Pages/KanbanBoardPage.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ public function titleField(string $field): static
8989
* Set the description field for the Kanban cards.
9090
*
9191
* @param string $field
92+
* @return KanbanBoardPage
9293
*/
9394
public function descriptionField(string $field): static
9495
{
@@ -125,6 +126,7 @@ public function columnColors(array $colors): static
125126
* Set the order field for the Kanban board.
126127
*
127128
* @param string $field
129+
* @return KanbanBoardPage
128130
*/
129131
public function orderField(string $field): static
130132
{

0 commit comments

Comments
 (0)