diff --git a/README.md b/README.md index 2ef4c5d..000b9a1 100644 --- a/README.md +++ b/README.md @@ -90,6 +90,11 @@ GazeBanner::make() GazeBanner::make() ->hidden(fn (?Order $record) => $record === null), ``` +There is also a helper function +```php +GazeBanner::make() + ->hideOnCreate(), +``` ## Docs @@ -126,6 +131,11 @@ GazeBanner::make() #### Arguments `fnc` - (optional, closure | bool) If the user can take control of the resource. Default is true. If a closure is passed, it should return a bool. +### `->hideOnCreate()` + +#### Description +`hideOnCreate` is a helper function that can be used to hide the banner on create forms. + ## Author diff --git a/src/Forms/Components/GazeBanner.php b/src/Forms/Components/GazeBanner.php index ed76b60..549246e 100644 --- a/src/Forms/Components/GazeBanner.php +++ b/src/Forms/Components/GazeBanner.php @@ -101,6 +101,17 @@ function () { return $this; } + /* + * Helper function to hide on create + */ + + public function hideOnCreate(): static + { + $this->hidden(fn ($record) => $record === null); + + return $this; + } + /** * Set the take control state */