@php
    $authCheck = auth()->check();
    $permission= auth()->user();
 @endphp  
<table class="table table-striped">
                        <thead class="border-bottom">
                            <tr>
                                <th>S.No.</th>
                                {{-- <th>Image</th> --}}
                                <th>User Name</th>
                                <th>Email</th>
                                <th>Role</th>
                                <th>Status</th>
                                <th>Action</th>
                               
                            </tr>
                        </thead>
                        <tbody>
                            @foreach($users as $key => $user)
                            <tr>
                                <td>{{ $key + 1 }}</td>
                                {{-- <td>
                                    <img src="{{ file_exists(public_path('storage/user/' . $user->image)) && $user->image
                                        ? url('storage/user/' . $user->image)
                                        : asset('img/no-image.png') }}"
                                    alt="" class="rounded-circle"
                                    style="max-width: 50px; max-height: 50px;">
                                </td>
                                 --}}
                                {{-- <td>{{ $user->name }}</td> --}}

                                <td>
                                    <div class="d-flex align-items-center">
                                        <img src="{{ file_exists(public_path('storage/user/' . $user->image)) && $user->image
                                            ? url('storage/user/' . $user->image)
                                            : asset('img/no-image.png') }}"
                                            alt="" class="rounded-circle me-2"
                                            style="width: 50px; height: 50px; object-fit: cover;">
                                        <span>{{ $user->name }}</span>
                                    </div>
                                </td>
                                <td>{{ $user->email }}</td>
                                <td>{{ $user->role()->pluck('name')->join(', ') }}</td>

                                <td class="ms-2" id="statusLabel{{ $user->id }}">
                                    {{ $user->status == 1 ? 'Active' : 'Inactive' }}
                                </td>

                                <td>
                                    <div class="d-flex align-items-center">
                                        <div class="lights">
                                            <div class="form-check form-switch mb-0 h-100">
                                                <input 
                                                    class="form-check-input mt-0 change-status" 
                                                    data-bs-toggle="tooltip" data-bs-placement="top" title="Status"
                                                    type="checkbox" 
                                                    id="statusSwitch{{ $user->id }}" 
                                                    name="statusSwitch" 
                                                    value="1"
                                                    data-id="{{ base64_encode($user->id) }}"
                                                    data-name="{{ $user->title }}"
                                                    {{ $user->status == 1 ? 'checked' : '' }}
                                                >
                                                
                                            </div>
                                        </div>
                                        @if($authCheck && $permission->hasPermission('user-edit'))
                                        <a href="{{ route('admin.users.edit', base64_encode($user->id)) }}" class="text-success me-2" data-bs-toggle="tooltip" data-bs-placement="top" title="Edit">
                                            <i class="fa-solid fa-pen-to-square"></i>
                                        </a>
                                        @endif
                                    </div>
                                </td>
                            </tr>
                            @endforeach
                          
                        </tbody>
                    </table>
                    <div class="pagination-wrapper mb-4">
                        {{ $users->links() }}
                    </div>
