File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Expand file tree Collapse file tree 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
9292
9393 $ this ->collection ->push (new Column ($ attributes ));
9494 } 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+ }
96100 }
97101 }
98102
Original file line number Diff line number Diff line change @@ -287,4 +287,19 @@ public function it_has_editors()
287287 ]);
288288 $ this ->assertCount (2 , $ builder ->getEditors ());
289289 }
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+ }
290305}
You can’t perform that action at this time.
0 commit comments