Skip to content

Commit

Permalink
Merge pull request #238 from lara-zeus/small-refactor
Browse files Browse the repository at this point in the history
small refactor on Navigation Badges Visibility
  • Loading branch information
atmonshi authored Jan 13, 2024
2 parents c848964 + 2136a1e commit df3017f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ public function showNavigationBadges(Closure | bool $show = true, ?Resources $re

private function setShowNavigationBadges(Closure | bool $show = true, ?Resources $resource = null): static
{
if (! is_null($resource)) {
if ($resource !== null) {
$this->showNavigationBadgesArray[$resource->value] = $show;
} else {
$this->showNavigationBadges = $show;
Expand All @@ -261,14 +261,14 @@ private function setShowNavigationBadges(Closure | bool $show = true, ?Resources

public function getShowNavigationBadges(?Resources $resource = null): bool
{
if (! is_null($resource)) {
if ($resource !== null) {
return $this->showNavigationBadgesArray[$resource->value] ?? $this->evaluate($this->showNavigationBadges);
}

return $this->evaluate($this->showNavigationBadges);
}

public static function getShowOrHideNavigationBadges(?Resources $resource = null): bool
public static function getNavigationBadgesVisibility(?Resources $resource = null): bool
{
return (new static())::get()->getShowNavigationBadges($resource);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Enums/Resources.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
enum Resources: string
{
case CategoryResource = 'CategoryResource';

case CollectionResource = 'CollectionResource';

case FormResource = 'FormResource';
}
2 changes: 1 addition & 1 deletion src/Filament/Resources/CategoryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static function getModel(): string

public static function getNavigationBadge(): ?string
{
if (! BoltPlugin::getShowOrHideNavigationBadges(Resources::CategoryResource)) {
if (! BoltPlugin::getNavigationBadgesVisibility(Resources::CategoryResource)) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Filament/Resources/CollectionResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static function getModel(): string

public static function getNavigationBadge(): ?string
{
if (! BoltPlugin::getShowOrHideNavigationBadges(Resources::CollectionResource)) {
if (! BoltPlugin::getNavigationBadgesVisibility(Resources::CollectionResource)) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Filament/Resources/FormResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static function getModel(): string

public static function getNavigationBadge(): ?string
{
if (! BoltPlugin::getShowOrHideNavigationBadges(Resources::FormResource)) {
if (! BoltPlugin::getNavigationBadgesVisibility(Resources::FormResource)) {
return null;
}

Expand Down

0 comments on commit df3017f

Please sign in to comment.