Skip to content

Commit

Permalink
Merge pull request #24 from Log1x/enhance/respect-is-visible
Browse files Browse the repository at this point in the history
πŸ§‘β€πŸ’» Respect `is_visible` when using `Menu::location`
  • Loading branch information
datlechin authored Aug 20, 2024
2 parents 396d054 + 2ed32ec commit 4d515a8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Models/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Datlechin\FilamentMenuBuilder\Models;

use Illuminate\Contracts\Database\Query\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;

Expand Down Expand Up @@ -39,7 +40,7 @@ public function menuItems(): HasMany

public static function location(string $location): ?self
{
return MenuLocation::with('menu')
return MenuLocation::with(['menu' => fn (Builder $query) => $query->where('is_visible', true)])
->where('location', $location)
->first()?->menu;
}
Expand Down

0 comments on commit 4d515a8

Please sign in to comment.