3030final readonly class KanbanConfig implements Wireable
3131{
3232 public function __construct (
33- private string $ columnField = 'status ' ,
34- private array $ columnValues = [],
35- private array | bool | null $ columnColors = null ,
36- private string $ titleField = 'title ' ,
37- private ?string $ descriptionField = null ,
38- private array $ cardAttributes = [],
39- private ?string $ orderField = null ,
40- private ?string $ cardLabel = null ,
41- private ?string $ pluralCardLabel = null ,
42- ) {}
33+ private string $ columnField = 'status ' ,
34+ private array $ columnValues = [],
35+ private array |bool |null $ columnColors = null ,
36+ private string $ titleField = 'title ' ,
37+ private ?string $ descriptionField = null ,
38+ private array $ cardAttributes = [],
39+ private ?array $ cardAttributeColors = [],
40+ private ?array $ cardAttributeIcons = [],
41+ private ?string $ orderField = null ,
42+ private ?string $ cardLabel = null ,
43+ private ?string $ pluralCardLabel = null ,
44+ )
45+ {
46+ }
4347
4448 /**
4549 * Get the field that stores the column value.
@@ -66,7 +70,7 @@ public function getColumnValues(): array
6670 *
6771 * @return array|bool|null Map of column values to color codes, or null if not set
6872 */
69- public function getColumnColors (): array | bool | null
73+ public function getColumnColors (): array | bool | null
7074 {
7175 return $ this ->columnColors ;
7276 }
@@ -101,6 +105,26 @@ public function getCardAttributes(): array
101105 return $ this ->cardAttributes ;
102106 }
103107
108+ /**
109+ * Get the colors for card attributes.
110+ *
111+ * @return array<string, string> Map of attribute names to color codes
112+ */
113+ public function getCardAttributeColors (): array
114+ {
115+ return $ this ->cardAttributeColors ?? [];
116+ }
117+
118+ /**
119+ * Get the icons for card attributes.
120+ *
121+ * @return array<string, string> Map of attribute names to icon names
122+ */
123+ public function getCardAttributeIcons (): array
124+ {
125+ return $ this ->cardAttributeIcons ?? [];
126+ }
127+
104128 /**
105129 * Get the field used for maintaining card order.
106130 *
@@ -130,8 +154,8 @@ public function getPluralCardLabel(): string
130154 /**
131155 * Get the default form schema for creating cards.
132156 *
133- * @param string $titleField The field name used for card titles
134- * @param string|null $descriptionField Optional field name for card descriptions
157+ * @param string $titleField The field name used for card titles
158+ * @param string|null $descriptionField Optional field name for card descriptions
135159 * @return array<Component> The default form schema
136160 */
137161 public static function getDefaultCreateFormSchema (string $ titleField , ?string $ descriptionField ): array
@@ -154,18 +178,19 @@ public static function getDefaultCreateFormSchema(string $titleField, ?string $d
154178 /**
155179 * Get the default form schema for editing cards.
156180 *
157- * @param string $titleField The field name used for card titles
158- * @param string|null $descriptionField Optional field name for card descriptions
159- * @param string $columnField The field name that determines which column a card belongs to
160- * @param array<string, string> $columnValues Available column values with their labels
181+ * @param string $titleField The field name used for card titles
182+ * @param string|null $descriptionField Optional field name for card descriptions
183+ * @param string $columnField The field name that determines which column a card belongs to
184+ * @param array<string, string> $columnValues Available column values with their labels
161185 * @return array<Component> The default form schema
162186 */
163187 public static function getDefaultEditFormSchema (
164- string $ titleField ,
188+ string $ titleField ,
165189 ?string $ descriptionField ,
166- string $ columnField ,
167- array $ columnValues
168- ): array {
190+ string $ columnField ,
191+ array $ columnValues
192+ ): array
193+ {
169194 $ schema = [
170195 TextInput::make ($ titleField )
171196 ->required ()
@@ -192,21 +217,21 @@ public static function getDefaultEditFormSchema(
192217 * For example, `withColumnField('status')` will create a new configuration
193218 * with the columnField property set to 'status'.
194219 *
195- * @param string $method The method name
196- * @param array $arguments The method arguments
220+ * @param string $method The method name
221+ * @param array $arguments The method arguments
197222 * @return self A new instance with the updated property
198223 *
199224 * @throws \BadMethodCallException If the method is not a valid with* method or targets a non-existent property
200225 */
201226 public function __call (string $ method , array $ arguments ): self
202227 {
203- if (! Str::startsWith ($ method , 'with ' )) {
228+ if (!Str::startsWith ($ method , 'with ' )) {
204229 throw new \BadMethodCallException ("Method {$ method } not found " );
205230 }
206231
207232 $ property = lcfirst (Str::after ($ method , 'with ' ));
208233
209- if (! property_exists ($ this , $ property )) {
234+ if (!property_exists ($ this , $ property )) {
210235 throw new \BadMethodCallException ("Property {$ property } not found " );
211236 }
212237
@@ -216,7 +241,7 @@ public function __call(string $method, array $arguments): self
216241 /**
217242 * Create a new configuration with the specified properties updated.
218243 *
219- * @param array<string, mixed> $properties The properties to update
244+ * @param array<string, mixed> $properties The properties to update
220245 * @return self A new instance with the updated properties
221246 */
222247 public function with (array $ properties ): self
@@ -239,6 +264,8 @@ public function toLivewire(): array
239264 'titleField ' => $ this ->titleField ,
240265 'descriptionField ' => $ this ->descriptionField ,
241266 'cardAttributes ' => $ this ->cardAttributes ,
267+ 'cardAttributeColors ' => $ this ->cardAttributeColors ,
268+ 'cardAttributeIcons ' => $ this ->cardAttributeIcons ,
242269 'orderField ' => $ this ->orderField ,
243270 'cardLabel ' => $ this ->cardLabel ,
244271 'pluralCardLabel ' => $ this ->pluralCardLabel ,
@@ -254,6 +281,8 @@ public static function fromLivewire($value): KanbanConfig
254281 $ value ['titleField ' ],
255282 $ value ['descriptionField ' ],
256283 $ value ['cardAttributes ' ],
284+ $ value ['cardAttributeColors ' ],
285+ $ value ['cardAttributeIcons ' ],
257286 $ value ['orderField ' ],
258287 $ value ['cardLabel ' ],
259288 $ value ['pluralCardLabel ' ]
0 commit comments