1313use Filament \Pages \Page ;
1414use Illuminate \Database \Eloquent \Builder ;
1515use Relaticle \Flowforge \Adapters \DefaultKanbanAdapter ;
16- use Relaticle \Flowforge \Config \KanbanConfig ;
17- use Relaticle \Flowforge \Contracts \KanbanAdapterInterface ;
18- use Relaticle \Flowforge \Contracts \HasBoard ;
1916use Relaticle \Flowforge \Concerns \HasRecords ;
2017use Relaticle \Flowforge \Concerns \InteractsWithBoard ;
18+ use Relaticle \Flowforge \Config \KanbanConfig ;
19+ use Relaticle \Flowforge \Contracts \HasBoard ;
20+ use Relaticle \Flowforge \Contracts \KanbanAdapterInterface ;
2121
22- abstract class BoardPage extends Page implements HasActions, HasForms, HasBoard
22+ abstract class BoardPage extends Page implements HasActions, HasBoard, HasForms
2323{
24- use InteractsWithActions;
25- use InteractsWithForms;
2624 use HasRecords;
25+ use InteractsWithActions;
2726 use InteractsWithBoard {
2827 InteractsWithBoard::moveRecord insteadof HasRecords;
2928 }
29+ use InteractsWithForms;
3030
3131 protected string $ view = 'flowforge::filament.pages.board-page ' ;
3232
@@ -41,12 +41,15 @@ abstract class BoardPage extends Page implements HasActions, HasForms, HasBoard
4141
4242 public function bootedInteractsWithActions (): void
4343 {
44- $ this -> bootedInteractsWithBoard ();
45- }
44+ // Recreate board fresh (Filament pattern)
45+ $ this -> board = $ this -> board (Board:: make ());
4646
47- public function bootedInteractsWithBoard (): void
48- {
49- $ this ->board = $ this ->makeBoard ();
47+ // Set the query on the board if not already set
48+ if (! $ this ->board ->getQuery ()) {
49+ $ this ->board ->query ($ this ->getEloquentQuery ());
50+ }
51+
52+ // Recreate adapter fresh (Filament pattern)
5053 $ this ->adapter = $ this ->createAdapter ();
5154 $ this ->cacheBoardActions ();
5255 }
@@ -94,7 +97,7 @@ public function getCachedBoardActions(): array
9497 /**
9598 * Check if an action is a record-based action that shouldn't be used as column action.
9699 */
97- public function isRecordBasedAction (Action | ActionGroup $ action ): bool
100+ public function isRecordBasedAction (Action | ActionGroup $ action ): bool
98101 {
99102 // ActionGroups themselves are not record-based, only individual actions within them can be
100103 if ($ action instanceof ActionGroup) {
@@ -149,14 +152,14 @@ public function getColumnActionsForColumn(string $columnId): array
149152 }
150153
151154 // Only include the group if it has valid actions
152- if (!empty ($ validGroupActions )) {
155+ if (! empty ($ validGroupActions )) {
153156 $ processedActions [] = $ actionClone ;
154157 }
155158 } else {
156159 // Handle individual actions
157160 $ this ->configureColumnAction ($ actionClone , $ columnId );
158161
159- if (!$ actionClone ->isHidden ()) {
162+ if (! $ actionClone ->isHidden ()) {
160163 $ processedActions [] = $ actionClone ;
161164 }
162165 }
@@ -195,7 +198,7 @@ public function getCardActionsForRecord(array $recordData): array
195198 $ recordModel = $ this ->getAdapter ()->getModelById ($ recordData ['id ' ]);
196199
197200 // If we can't find the record, return empty actions
198- if (!$ recordModel || !($ recordModel instanceof \Illuminate \Database \Eloquent \Model)) {
201+ if (! $ recordModel || ! ($ recordModel instanceof \Illuminate \Database \Eloquent \Model)) {
199202 return [];
200203 }
201204
@@ -227,7 +230,7 @@ public function getCardActionsForRecord(array $recordData): array
227230 }
228231
229232 // Safely check if action is hidden
230- if (!$ actionClone ->isHidden ()) {
233+ if (! $ actionClone ->isHidden ()) {
231234 $ processedActions [] = $ actionClone ;
232235 }
233236 } catch (\Exception $ e ) {
@@ -246,6 +249,7 @@ public function getCardActionsForRecord(array $recordData): array
246249 protected function makeBoard (): Board
247250 {
248251 $ board = Board::make ();
252+
249253 return $ this ->board ($ board );
250254 }
251255
@@ -268,7 +272,16 @@ protected function getTableQuery(): Builder
268272
269273 protected function createKanbanConfig (): KanbanConfig
270274 {
271- $ board = $ this ->getBoard ();
275+ // Ensure board is initialized before creating config
276+ if (! isset ($ this ->board )) {
277+ $ this ->board = $ this ->board (Board::make ());
278+ // Set the query on the board if not already set
279+ if (! $ this ->board ->getQuery ()) {
280+ $ this ->board ->query ($ this ->getEloquentQuery ());
281+ }
282+ }
283+
284+ $ board = $ this ->board ;
272285
273286 // Set columns configuration
274287 $ columns = [];
@@ -313,7 +326,7 @@ protected function createKanbanConfig(): KanbanConfig
313326
314327 public function getBoard (): Board
315328 {
316- return $ this ->board ??= $ this ->makeBoard ( );
329+ return $ this ->board ??= $ this ->board (Board:: make () );
317330 }
318331
319332 public function getAdapter (): KanbanAdapterInterface
@@ -326,11 +339,10 @@ public function getPageClass(): string
326339 return static ::class;
327340 }
328341
329-
330342 protected function getViewData (): array
331343 {
332344 return [
333- 'adapter ' => $ this ->adapter ,
345+ 'adapter ' => $ this ->getAdapter () ,
334346 'pageClass ' => static ::class,
335347 ];
336348 }
0 commit comments