From 8f8ef12981f5eb13fd7126df761d311a01f4b598 Mon Sep 17 00:00:00 2001 From: Ash Monsh Date: Tue, 29 Oct 2024 22:16:17 +0300 Subject: [PATCH 1/2] 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); + } +} From c3000eae4e7407a3633b4a4d28a1238fd810f21f Mon Sep 17 00:00:00 2001 From: atmonshi Date: Tue, 29 Oct 2024 19:16:42 +0000 Subject: [PATCH 2/2] Fix styling --- src/Concerns/CanDisableBadges.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Concerns/CanDisableBadges.php b/src/Concerns/CanDisableBadges.php index b9e28d4..adf1d6b 100644 --- a/src/Concerns/CanDisableBadges.php +++ b/src/Concerns/CanDisableBadges.php @@ -1,6 +1,7 @@ showNavigationBadgesArray[$resource] ?? $this->evaluate($this->showNavigationBadges);