Inertia:: share Auth not Executing

55 Views Asked by At

I have laravel with, inertia, and vue 3. So I try to access roles for each user with $inertia.page.props.auth.user and I setup the AppServiceProvider.php to get only id. But i get the whole data and after checking, the auth' => function () is not executing but route function is properly executed. What is happening?

    public function boot()
    {
        Inertia::share([

            'auth' => function () {
                return ['users' => Auth::user() ? Auth::user()->only('id', 'name') : null];
            },
            'route' => function () {
                return [
                    'name' => Route::currentRouteName(),
                ];
            },
        ]);
    }

Rendering the page-web.php

Route::get('/home', function () {
    return Inertia::render('Welcome', [
    ]);
})->name('home');;

0

There are 0 best solutions below