F
Filamentβ€’11mo ago
Clay Bitner

Adding a search to Tenant Menu

I'm trying to add a search to the Tenant menu for when the list of tenants is too long that it takes over the whole screen height. But I can't figure out how to add it or modify the menu. I tried creating a blade file with the name tenant-menu.blade.php and placing it in the resources/views/filament/components folder, but it doesn't seem to be reading that file to overwrite the original. What am I missing? Should I build a plugin for that instead?
Solution:
For anyone who's trying to figure it out themselves, I had the file in the wrong spot. It needed to go in reosources/views/vendor/filament-panels/components/tenant-menu.blade.php I was then able to add code to add a search box....
Jump to solution
3 Replies
Solution
Clay Bitner
Clay Bitnerβ€’11mo ago
For anyone who's trying to figure it out themselves, I had the file in the wrong spot. It needed to go in reosources/views/vendor/filament-panels/components/tenant-menu.blade.php I was then able to add code to add a search box.
Lukas Jankauskas
Lukas Jankauskasβ€’7mo ago
@Clay Bitner any chance you can share that bit of code? Would save me some time πŸ˜„
Clay Bitner
Clay BitnerOPβ€’6mo ago
@if ($canSwitchTenants)
<div x-data="{ search: '' }">
@if(count($tenants) > 8)
<x-filament::input.wrapper>
<x-filament::input
type="text"
x-model="search"
placeholder="Search tenants..."
class="w-full rounded-md border border-gray-300 px-2 py-1 text-sm"
/>
</x-filament::input.wrapper>
@endif

<div class="max-h-90 overflow-y-auto">
@foreach ($tenants as $tenant)
<div x-show="search === '' || '{{ e(filament()->getTenantName($tenant)) }}'.replace(/ /g, '').toLowerCase().includes(search.replace(/ /g, '').toLowerCase())">
<x-filament::dropdown.list.item
:href="filament()->getUrl($tenant)"
:image="filament()->getTenantAvatarUrl($tenant)"
tag="a"
>
{{ filament()->getTenantName($tenant) }}
</x-filament::dropdown.list.item>
</div>
@endforeach
</div>
</div>
@endif
@if ($canSwitchTenants)
<div x-data="{ search: '' }">
@if(count($tenants) > 8)
<x-filament::input.wrapper>
<x-filament::input
type="text"
x-model="search"
placeholder="Search tenants..."
class="w-full rounded-md border border-gray-300 px-2 py-1 text-sm"
/>
</x-filament::input.wrapper>
@endif

<div class="max-h-90 overflow-y-auto">
@foreach ($tenants as $tenant)
<div x-show="search === '' || '{{ e(filament()->getTenantName($tenant)) }}'.replace(/ /g, '').toLowerCase().includes(search.replace(/ /g, '').toLowerCase())">
<x-filament::dropdown.list.item
:href="filament()->getUrl($tenant)"
:image="filament()->getTenantAvatarUrl($tenant)"
tag="a"
>
{{ filament()->getTenantName($tenant) }}
</x-filament::dropdown.list.item>
</div>
@endforeach
</div>
</div>
@endif
Want results from more Discord servers?
Add your server