diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index 86abc7e2..5e5da7e7 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -6,6 +6,8 @@ use App\Enums\VoucherSetType; use App\Models\Country; use App\Models\Team; +use App\Models\TeamUser; +use Auth; use Illuminate\Http\Request; use Inertia\Middleware; @@ -41,10 +43,11 @@ public function share(Request $request): array return [ ...parent::share($request), - 'auth' => [ - 'user' => $request->user(), - 'currentTeam' => $team, - 'teamCountry' => Country::find($team?->country_id), + 'auth' => [ + 'user' => $request->user(), + 'currentTeam' => $team, + 'availableTeams' => TeamUser::with('team')->where('user_id', Auth::id())->get(), + 'teamCountry' => Country::find($team?->country_id), ], 'personalAccessTokenAbilities' => PersonalAccessTokenAbility::groupsAbilityCasesWithDefinitions(), 'platformAppTokenAbilities' => PersonalAccessTokenAbility::platformAppTokenAbilities(), diff --git a/resources/js/Layouts/AuthenticatedLayout.vue b/resources/js/Layouts/AuthenticatedLayout.vue index 599ada16..54195460 100644 --- a/resources/js/Layouts/AuthenticatedLayout.vue +++ b/resources/js/Layouts/AuthenticatedLayout.vue @@ -5,7 +5,7 @@ import Dropdown from '@/Components/Dropdown.vue'; import DropdownLink from '@/Components/DropdownLink.vue'; import NavLink from '@/Components/NavLink.vue'; import ResponsiveNavLink from '@/Components/ResponsiveNavLink.vue'; -import {Link} from '@inertiajs/vue3'; +import {Link, usePage} from '@inertiajs/vue3'; import PrimaryButton from "@/Components/PrimaryButton.vue"; import SearchComponent from "@/Components/App/Search/SearchComponent.vue"; @@ -13,6 +13,7 @@ const showingNavigationDropdown = ref(false);