Dev0ps
1 year ago

how to get users friend birthdays list

Posted 1 year ago by Dev0ps

i have a birthday page where i show all friends list along with there birthday

i create a code which gives me friends id. now how to check

$friendships = Friend::whereStatus(2)->whereUserId(Auth::id())->get(['user_id', 'friend_id']);
            $friend_id  = $friendships->pluck('friend_id')->all();
            $user_id     = $friendships->pluck('user_id')->all();
            $myFriends = Friend::where('friend_id', '!=', Auth::id())->whereIn('friend_id', array_merge($friend_id))->whereIn('user_id', array_merge($user_id))->get();
            $myFriends = $myFriends->pluck('friend_id')->toArray();
            $data['friends'] = $myFriends;

currently i use this

@foreach(\App\User::whereMonth('birthday', 6)->get() as $Friend)
                        <div class="birthday-item inline-items">
                            <div class="author-thumb">
                                <img src="{{ asset(\App\Avatar::orderBy('id','desc')->where('username', '=', $Friend->username)->first()->source)}}" height="36" width="36" alt="author">
                            </div>
                            <div class="birthday-author-name">
                                <a href="#" class="h6 author-name">{{$Friend->first_name. ' ' .$Friend->last_name}} </a>
                                <div class="birthday-date">{{Carbon\Carbon::parse($Friend->birthday)->toFormattedDateString()}}</div>
                            </div>
                            <a href="20-CalendarAndEvents-MonthlyCalendar" class="btn btn-sm bg-blue">Create Event</a>
                        </div>

but it shows all users birthday :( not only friends

Please sign in or create an account to participate in this conversation.