@@ -67,7 +67,7 @@ class KanbanBoard extends Component implements HasForms
6767 /**
6868 * The active card for modal operations.
6969 */
70- public string | int | null $ currentRecord = null ;
70+ public string | int | null $ currentRecord = null ;
7171
7272 /**
7373 * Search query for filtering cards.
@@ -103,17 +103,18 @@ class KanbanBoard extends Component implements HasForms
103103 /**
104104 * Initialize the Kanban board.
105105 *
106- * @param KanbanAdapterInterface $adapter The Kanban adapter
107- * @param int|null $initialCardsCount The initial number of cards to load per column
108- * @param int|null $cardsIncrement The number of cards to load on "load more"
109- * @param array<int, string> $searchable The searchable fields
106+ * @param KanbanAdapterInterface $adapter The Kanban adapter
107+ * @param int|null $initialCardsCount The initial number of cards to load per column
108+ * @param int|null $cardsIncrement The number of cards to load on "load more"
109+ * @param array<int, string> $searchable The searchable fields
110110 */
111111 public function mount (
112112 KanbanAdapterInterface $ adapter ,
113- ?int $ initialCardsCount = null ,
114- ?int $ cardsIncrement = null ,
115- array $ searchable = []
116- ): void {
113+ ?int $ initialCardsCount = null ,
114+ ?int $ cardsIncrement = null ,
115+ array $ searchable = []
116+ ): void
117+ {
117118 $ this ->adapter = $ adapter ;
118119 $ this ->searchable = $ searchable ;
119120 $ this ->config = $ this ->adapter ->getConfig ();
@@ -130,7 +131,7 @@ public function mount(
130131
131132 // Initialize columns
132133 $ this ->columns = collect ($ this ->config ->getColumnValues ())
133- ->map (fn ($ label , $ value ) => [
134+ ->map (fn ($ label , $ value ) => [
134135 'id ' => $ value ,
135136 'label ' => $ label ,
136137 'color ' => $ this ->resolveColumnColors ()[$ value ] ?? null ,
@@ -250,30 +251,30 @@ protected function loadColumnsData(): void
250251 /**
251252 * Get items for a specific column.
252253 *
253- * @param string|int $columnId The column ID
254+ * @param string|int $columnId The column ID
254255 * @return array The formatted items
255256 */
256- public function getItemsForColumn (string | int $ columnId ): array
257+ public function getItemsForColumn (string | int $ columnId ): array
257258 {
258259 return $ this ->columnCards [$ columnId ] ?? [];
259260 }
260261
261262 /**
262263 * Get the total count of items for a specific column.
263264 *
264- * @param string|int $columnId The column ID
265+ * @param string|int $columnId The column ID
265266 * @return int The total count
266267 */
267- public function getColumnItemsCount (string | int $ columnId ): int
268+ public function getColumnItemsCount (string | int $ columnId ): int
268269 {
269270 return $ this ->adapter ->getColumnItemsCount ($ columnId );
270271 }
271272
272273 /**
273274 * Load more items for a column.
274275 *
275- * @param string $columnId The column ID
276- * @param int|null $count The number of items to load
276+ * @param string $columnId The column ID
277+ * @param int|null $count The number of items to load
277278 */
278279 public function loadMoreItems (string $ columnId , ?int $ count = null ): void
279280 {
@@ -291,7 +292,7 @@ public function loadMoreItems(string $columnId, ?int $count = null): void
291292 /**
292293 * Format items for display.
293294 *
294- * @param Collection $items The items to format
295+ * @param Collection $items The items to format
295296 * @return array The formatted items
296297 */
297298 protected function formatItems (Collection $ items ): array
@@ -302,8 +303,8 @@ protected function formatItems(Collection $items): array
302303 /**
303304 * Update the order of cards in a column.
304305 *
305- * @param string|int $columnId The column ID
306- * @param array $cardIds The card IDs in their new order
306+ * @param string|int $columnId The column ID
307+ * @param array $cardIds The card IDs in their new order
307308 * @return bool Whether the operation was successful
308309 */
309310 public function updateRecordsOrderAndColumn ($ columnId , $ cardIds ): bool
@@ -320,7 +321,7 @@ public function updateRecordsOrderAndColumn($columnId, $cardIds): bool
320321 /**
321322 * Open the create form modal.
322323 *
323- * @param string $columnId The column ID for the new card
324+ * @param string $columnId The column ID for the new card
324325 */
325326 public function openCreateForm (string $ columnId ): void
326327 {
@@ -338,17 +339,17 @@ public function openCreateForm(string $columnId): void
338339 /**
339340 * Open the edit form modal.
340341 *
341- * @param string|int $recordId The card ID to edit
342- * @param string|int $columnId The column ID containing the card
342+ * @param string|int $recordId The card ID to edit
343+ * @param string|int $columnId The column ID containing the card
343344 */
344- public function openEditForm (string | int $ recordId , string | int $ columnId ): void
345+ public function openEditForm (string | int $ recordId , string | int $ columnId ): void
345346 {
346347 $ this ->currentColumn = $ columnId ;
347348 $ this ->currentRecord = $ recordId ;
348349
349350 $ record = $ this ->adapter ->getModelById ($ recordId );
350351
351- if (! $ record ) {
352+ if (!$ record ) {
352353 Notification::make ()
353354 ->title ('Card not found ' )
354355 ->danger ()
@@ -376,7 +377,7 @@ public function openEditForm(string | int $recordId, string | int $columnId): vo
376377 */
377378 public function createRecord (): void
378379 {
379- if (! $ this ->permissions ['canCreate ' ]) {
380+ if (!$ this ->permissions ['canCreate ' ]) {
380381 Notification::make ()
381382 ->title ('You do not have permission to create records ' )
382383 ->danger ()
@@ -385,23 +386,14 @@ public function createRecord(): void
385386 return ;
386387 }
387388
388- // Use form state to get data with validation applied
389- $ data = $ this ->createRecordForm ->getState ();
390-
391- // Ensure column field is set
392- $ columnField = $ this ->config ->getColumnField ();
393- if (! isset ($ data [$ columnField ])) {
394- $ data [$ columnField ] = $ this ->currentColumn ;
395- }
396-
397- $ card = $ this ->adapter ->createRecord ($ data , $ this ->currentColumn );
389+ $ record = $ this ->adapter ->createRecord ($ this ->createRecordForm , $ this ->currentColumn );
398390
399- if ($ card ) {
391+ if ($ record ) {
400392 $ this ->refreshBoard ();
401393 $ this ->resetCreateForm ();
402394
403395 $ this ->dispatch ('kanban-record-created ' , [
404- 'record ' => $ card ,
396+ 'record ' => $ record ,
405397 ]);
406398
407399 Notification::make ()
@@ -433,11 +425,9 @@ private function resetCreateForm(): void
433425 */
434426 public function updateRecord (): void
435427 {
436- // Use form state to get data with any relationship handling applied
437- $ data = $ this ->editRecordForm ->getState ();
438428 $ record = $ this ->adapter ->getModelById ($ this ->currentRecord );
439429
440- if (! $ record ) {
430+ if (!$ record ) {
441431 Notification::make ()
442432 ->title (__ (':Record not found ' , ['record ' => $ this ->config ->getSingularCardLabel ()]))
443433 ->danger ()
@@ -446,7 +436,7 @@ public function updateRecord(): void
446436 return ;
447437 }
448438
449- $ success = $ this ->adapter ->updateRecord ($ record , $ data );
439+ $ success = $ this ->adapter ->updateRecord ($ record , $ this -> editRecordForm );
450440
451441 if ($ success ) {
452442 $ this ->refreshBoard ();
@@ -483,10 +473,10 @@ public function resetEditForm(): void
483473 /**
484474 * Open the delete confirmation modal.
485475 *
486- * @param string|int $cardId The card ID to delete
487- * @param string $columnId The column ID containing the card
476+ * @param string|int $cardId The card ID to delete
477+ * @param string $columnId The column ID containing the card
488478 */
489- public function confirmDelete (string | int $ cardId , string $ columnId ): void
479+ public function confirmDelete (string | int $ cardId , string $ columnId ): void
490480 {
491481 $ this ->currentRecord = $ cardId ;
492482 $ this ->currentColumn = $ columnId ;
@@ -497,7 +487,7 @@ public function confirmDelete(string | int $cardId, string $columnId): void
497487 */
498488 public function deleteRecord (): void
499489 {
500- if (! $ this ->permissions ['canDelete ' ]) {
490+ if (!$ this ->permissions ['canDelete ' ]) {
501491 Notification::make ()
502492 ->title (__ ('You do not have permission to delete :records ' , ['records ' => $ this ->config ->getPluralCardLabel ()]))
503493 ->danger ()
@@ -508,7 +498,7 @@ public function deleteRecord(): void
508498
509499 $ record = $ this ->adapter ->getModelById ($ this ->currentRecord );
510500
511- if (! $ record ) {
501+ if (!$ record ) {
512502 Notification::make ()
513503 ->title ('Record not found ' )
514504 ->danger ()
0 commit comments