How to get user information using hootlex/laravel-friendships package in laravel

Updated at 06-Sep-2021, By samar

How to get user information using hootlex/laravel-friendships package in laravel

In this article, we will see how to solve "How to get user information using hootlex/laravel-friendships package in laravel".

You can get the user information using hootlex/laravel-friendships package in laravel. Sometimes we want to access user information like name, image to display in view file in that case it helps you to access users table column data.
  • Laravel friendship get user information using hootlex/laravel-friendships

    {{ $invitation->sender->name }}
    
    //Get all the invitations for friendship from other users using getFriendRequests() method
    $invitations =  Auth::user()->getFriendRequests();
    return view('home')->with(['invitations'=>$invitations]);
    
    //Display user information in view file
    //resources\views\home.blade.php
    @foreach($invitations as $invitation)
        {{ $invitation->sender->name }}
    @endforeach
    

    This code snippet helps you to get the user information like user id, name and others field value from users table who send the invitations for connect to logged in user.

Back to code snippet queries related laravel