@@ -97,9 +97,10 @@ public function updateRecordsOrderAndColumn(string $columnId, array $recordIds):
9797
9898 $ updateData = [$ statusField => $ statusValue ];
9999
100- // Add sort order if the model has that column
101- if ($ this ->modelHasSortOrder ($ record )) {
102- $ updateData ['sort_order ' ] = $ index ;
100+ // Add sort order if reordering is configured
101+ $ reorderBy = $ board ->getReorderBy ();
102+ if ($ reorderBy && $ this ->modelHasOrderColumn ($ record , $ reorderBy ['column ' ])) {
103+ $ updateData [$ reorderBy ['column ' ]] = $ index ;
103104 }
104105
105106 $ success = $ record ->update ($ updateData ) && $ success ;
@@ -110,15 +111,15 @@ public function updateRecordsOrderAndColumn(string $columnId, array $recordIds):
110111 }
111112
112113 /**
113- * Check if model has sort_order column.
114+ * Check if model has the specified order column.
114115 */
115- protected function modelHasSortOrder ($ model ): bool
116+ protected function modelHasOrderColumn ($ model, string $ columnName ): bool
116117 {
117118 try {
118119 $ table = $ model ->getTable ();
119120 $ schema = $ model ->getConnection ()->getSchemaBuilder ();
120121
121- return $ schema ->hasColumn ($ table , ' sort_order ' );
122+ return $ schema ->hasColumn ($ table , $ columnName );
122123 } catch (Exception ) {
123124 return false ;
124125 }
@@ -194,11 +195,15 @@ public function getBoardColumnRecords(string $columnId): array
194195 $ statusField = $ board ->getColumnIdentifierAttribute () ?? 'status ' ;
195196 $ limit = $ this ->columnCardLimits [$ columnId ] ?? 10 ;
196197
197- return (clone $ query )
198- ->where ($ statusField , $ columnId )
199- ->limit ($ limit )
200- ->get ()
201- ->toArray ();
198+ $ queryClone = (clone $ query )->where ($ statusField , $ columnId );
199+
200+ // Apply ordering if configured
201+ $ reorderBy = $ board ->getReorderBy ();
202+ if ($ reorderBy ) {
203+ $ queryClone ->orderBy ($ reorderBy ['column ' ], $ reorderBy ['direction ' ]);
204+ }
205+
206+ return $ queryClone ->limit ($ limit )->get ()->toArray ();
202207 }
203208
204209 /**
0 commit comments