diff --git a/src/Html/Options/HasColumns.php b/src/Html/Options/HasColumns.php
index f605259..5444ce0 100644
--- a/src/Html/Options/HasColumns.php
+++ b/src/Html/Options/HasColumns.php
@@ -92,7 +92,11 @@ public function columns(array $columns): static
$this->collection->push(new Column($attributes));
} else {
- $this->collection->push($value);
+
+ // Only add the column if it is authorized, otherwise ignore it.
+ if ($value->isAuthorized()) {
+ $this->collection->push($value);
+ }
}
}
diff --git a/tests/BuilderTest.php b/tests/BuilderTest.php
index 62d4fa6..b4a140e 100644
--- a/tests/BuilderTest.php
+++ b/tests/BuilderTest.php
@@ -287,4 +287,19 @@ public function it_has_editors()
]);
$this->assertCount(2, $builder->getEditors());
}
+
+ #[Test]
+ public function it_ignores_unauthorized_columns(): void
+ {
+ $builder = $this->getHtmlBuilder();
+
+ $builder->columns([
+ Column::makeIf(false)
+ ->title('unauthorized_column'),
+
+ Column::make('authorized_column'),
+ ]);
+
+ $this->assertCount(1, $builder->getColumns());
+ }
}