Skip to content

Commit 8bbabf3

Browse files
thapacodes4uankitcodes4u
andauthored
fix: type error in tenant menu when current tenant is null (#27)
Co-authored-by: ankitcodes4u <ankitcodes4u@gmail.com>
1 parent a405c8c commit 8bbabf3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

resources/views/filament/components/tenant-menu.blade.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
@php
2+
use Illuminate\Database\Eloquent\Model;
3+
24
$currentTenant = filament()->getTenant();
3-
$currentTenantName = filament()->getTenantName($currentTenant);
5+
$currentTenantName = $currentTenant ? filament()->getTenantName($currentTenant) : null;
46
5-
$canSwitchTenants = count(
7+
$canSwitchTenants = $currentTenant ? count(
68
$tenants = array_filter(
79
filament()->getUserTenants(filament()->auth()->user()),
8-
fn(\Illuminate\Database\Eloquent\Model $tenant): bool => !$tenant->is($currentTenant),
10+
fn(Model $tenant): bool => $tenant && !$tenant->is($currentTenant),
911
),
10-
);
12+
) : 0;
1113
@endphp
14+
@if($currentTenant)
1215
<x-filament::dropdown placement="bottom-start" size teleport>
1316
<x-slot name="trigger">
1417
<button type="button"
@@ -23,11 +26,14 @@ class="ms-auto h-5 w-5 shrink-0 text-gray-400 transition duration-75 group-hover
2326
@if ($canSwitchTenants)
2427
<x-filament::dropdown.list>
2528
@foreach ($tenants as $tenant)
29+
@if($tenant)
2630
<x-filament::dropdown.list.item :href="route('filament.admin.pages.dashboard', ['tenant' => $tenant])" :image="filament()->getTenantAvatarUrl($tenant)" tag="a">
2731
{{ filament()->getTenantName($tenant) }}
2832
</x-filament::dropdown.list.item>
33+
@endif
2934
@endforeach
3035
</x-filament::dropdown.list>
3136
@endif
3237

3338
</x-filament::dropdown>
39+
@endif

0 commit comments

Comments
 (0)