Is there a way of getting authenticated user ID and use it on navigation.blade? - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Saturday, February 26, 2022

Is there a way of getting authenticated user ID and use it on navigation.blade?

I'm building a new Laravel app, using Breeze. What i'm trying to do is get the authenticated user id to redirect it to the profile route, which is:

Route::group([
    'prefix' => 'profile',
    'as' => 'profile.',
    'middleware' => ['auth']
], function () {
    Route::get('/{id}',  [ProfileController::class, 'show'])->name('profile');
}
);

But, on the layout of navigation, as shown below, i can't manage to get it on the :href. I already tried some approaches, like:

:href=""
:href=""

But none of them seems to work.

The navigation.blade.php dropdown part:

   <x-slot name="content">
                    <x-dropdown-link :href="route('admin.aprovar')">
                                
                            </x-dropdown-link>
                            <x-dropdown-link>
                                
                            </x-dropdown-link>
                        <!-- Authentication -->
                        <form method="POST" action="">
                            @csrf

                            <x-dropdown-link :href="route('logout')"
                                    onclick="event.preventDefault();
                                                this.closest('form').submit();">
                                
                            </x-dropdown-link>
                        </form>
                    </x-slot>

Any help or hint would be appreciated. Thanks for your time!



source https://stackoverflow.com/questions/71269847/is-there-a-way-of-getting-authenticated-user-id-and-use-it-on-navigation-blade

No comments:

Post a Comment