skip to Main Content

all members see the same counts in the software. How can I make it count specifically for user_id?

 @php $check_count = AppModelsSupport::where('status', 2)->get()
 @endphp
 
<li class="header__menu-item"> <span>Support</span>
 @if(count($check_count) == 0)  @else   <span class="notification
 notranslate">{{count($check_count)}}</span> @endif </li>

mysql picture

I wanted to count notifications based on user_id, but I couldn’t manage to count them based on member.

2

Answers


  1.     @php
    $user_id = auth()->user()->id; // Assuming you are using Laravel authentication and the user is logged in
    $check_count = AppModelsSupport::where('user_id', $user_id)
                                      ->where('status', 2)
                                      ->get();
    @endphp
    
    <li class="header__menu-item">
        <span>Support</span>
        @if(count($check_count) == 0)
        @else
            <span class="notification notranslate">{{ count($check_count) }}</span>
        @endif
    </li>
    
    Login or Signup to reply.
  2.  @php $check_count = AppModelsSupport::all()->where('user_id', Auth::user()->id) @endphp
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search