Search code examples
phplaravelvuejs3inertiajslaravel-breeze

Laravel Breeze w/Inertia & Vue Dashboard view User Data


I'm using Laravel with Breeze along with Inertia and Vue.

I am looking at my Vue Dev tool while on the dashboard view and I can see my table schema and the user's strip ID. I would like more control over what is accessible here, however, I cannot find where the page is getting the data from. I can see the request, and even the query with clockwork, but I can't find where the request is being made within the code. Does anyone know where to look?Vue Devtools showing table schema


Solution

  • The auth.user shared data comes from here, in the HandleInertiaRequests middleware.

        public function share(Request $request): array
        {
            return array_merge(parent::share($request), [
                'auth' => [
                    'user' => $request->user(),
                ],
                'ziggy' => function () use ($request) {
                    return array_merge((new Ziggy)->toArray(), [
                        'location' => $request->url(),
                    ]);
                },
            ]);
        }
    

    This makes these items available in all Inertia responses.