Skip to content

Commit

Permalink
Merge pull request #29 from salahhusa9/badgeName-as-callable
Browse files Browse the repository at this point in the history
badgeName can be Closure
  • Loading branch information
salahhusa9 committed May 20, 2024
2 parents e082c42 + 268a669 commit a7a05bb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion resources/views/components/menu.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@

@if ($item->badgeName)
<div class="{{ $menu->getConfig('badge_class') }} {{ $item->badgeClass }}">
{{ $item->badgeName }}
@if (is_callable($item->badgeName))
{{ call_user_func($item->badgeName) }}
@else
{{ $item->badgeName }}
@endif
</div>
@endif
</a>
Expand Down
4 changes: 2 additions & 2 deletions src/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Item
public $badgeClass;

/**
* @var string
* @var string|Closure
*/
public $badgeName;

Expand All @@ -66,7 +66,7 @@ class Item
* @param string $id
* @param string $target
* @param string $badgeClass
* @param string $badgeName
* @param string|Closure $badgeName
* @param string array $gateName
* @return Item
*/
Expand Down

0 comments on commit a7a05bb

Please sign in to comment.