File tree 2 files changed +20
-1
lines changed
2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,11 @@ public function columns(array $columns): static
92
92
93
93
$ this ->collection ->push (new Column ($ attributes ));
94
94
} else {
95
- $ this ->collection ->push ($ value );
95
+
96
+ // Only add the column if it is authorized, otherwise ignore it.
97
+ if ($ value ->isAuthorized ()) {
98
+ $ this ->collection ->push ($ value );
99
+ }
96
100
}
97
101
}
98
102
Original file line number Diff line number Diff line change @@ -287,4 +287,19 @@ public function it_has_editors()
287
287
]);
288
288
$ this ->assertCount (2 , $ builder ->getEditors ());
289
289
}
290
+
291
+ #[Test]
292
+ public function it_ignores_unauthorized_columns (): void
293
+ {
294
+ $ builder = $ this ->getHtmlBuilder ();
295
+
296
+ $ builder ->columns ([
297
+ Column::makeIf (false )
298
+ ->title ('unauthorized_column ' ),
299
+
300
+ Column::make ('authorized_column ' ),
301
+ ]);
302
+
303
+ $ this ->assertCount (1 , $ builder ->getColumns ());
304
+ }
290
305
}
You can’t perform that action at this time.
0 commit comments