From 8f8ef12981f5eb13fd7126df761d311a01f4b598 Mon Sep 17 00:00:00 2001 From: Ash Monsh Date: Tue, 29 Oct 2024 22:16:17 +0300 Subject: [PATCH] Create CanDisableBadges.php --- src/Concerns/CanDisableBadges.php | 46 +++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/Concerns/CanDisableBadges.php diff --git a/src/Concerns/CanDisableBadges.php b/src/Concerns/CanDisableBadges.php new file mode 100644 index 0000000..b9e28d4 --- /dev/null +++ b/src/Concerns/CanDisableBadges.php @@ -0,0 +1,46 @@ +setShowNavigationBadges($show, $resource); + } + + public function showNavigationBadges(Closure | bool $show = true, ?string $resource = null): static + { + return $this->setShowNavigationBadges($show, $resource); + } + + private function setShowNavigationBadges(Closure | bool $show = true, ?string $resource = null): static + { + if ($resource !== null) { + $this->showNavigationBadgesArray[$resource] = $show; + } else { + $this->showNavigationBadges = $show; + } + + return $this; + } + + public function getShowNavigationBadges(string $resource = null): bool + { + if ($resource !== null) { + return $this->showNavigationBadgesArray[$resource] ?? $this->evaluate($this->showNavigationBadges); + } + + return $this->evaluate($this->showNavigationBadges); + } + + public static function getNavigationBadgesVisibility($resource = null): bool + { + return (new static)::get()->getShowNavigationBadges($resource); + } +}