 <div class="table-responsive">
  <table id="example" class="table table-bordered align-middle" style="width:100%">
    <thead class="table-light">
      <tr>
        <th>Sl No</th>
        <th>User Name</th>
        <th>Role</th>
        <th>Phone No</th>
        <th>Company Name</th>
        <th class = "thbutton">User Type</th>
        <th class = "thbutton">Status</th>
        <th class = "thbutton">Edit</th>
        <th class = "thbutton">Delete</th>
    </tr>
</thead>
<tbody>
    @php $i=1;@endphp
    @if(count($Userdata)>0)
    @foreach($Userdata as $key=> $list)
    <tr>
        <td>{{$Userdata->firstItem() + $key}}</td>
        <td>{{$list->name}} <br> {{$list->email}}</td>
        @php
            $roles = explode(',', $list->getRoleNames());
        @endphp
        <td>
            @foreach($roles as $key => $value)
                @php
                    $role = str_replace(']', '', $value);
                    $role = str_replace('[', '', $role);
                    $role = str_replace('"', '', $role);
                @endphp
                @if($role != '')
                    <span class="badge badge-pill bg-success">{!! ucfirst($role) !!}</span>
                @endif
            @endforeach
        </td>
        <td>{{$list->phone_no }} <br>{{$list->whatsapp_no }}</td>
        <td>@if(isset($list->getComapnyDetails->name)){{$list->getComapnyDetails->name}}@endif</td>

        <td>
            @if(in_array('Admin',auth::user()->roles->pluck('name')->all()))
            <select class="form-control" name="user_type" data-id="{{ $list->id }}" id="user_type_{{ $list->id }}">
                @foreach($user_types as $type)
                    <option value="{{ $type->code }}" 
                        @if($list->user_type === $type->code)
                            selected
                        @endif>
                        {{ ucfirst($type->name) }}
                    </option>
                @endforeach
            </select>
            @else
                {!! ucfirst($list->user_type) !!}
            @endif
        </td>

        <td>
            @if(in_array('users-edit', $authRolePermissions))
            <div class="form-check form-check-inline{{$i}}">
                <input class="form-check-input{{$i}} btn-lg changeStatusCustom" type="checkbox" id="inlineCheckbox{{$i}}" data-url="{{route('users.changestatus')}}" data-id="{{$list->id}}" data-status="@if($list->status=='0'){{'1'}}@elseif($list->status=='1'){{'0'}}@endif" @if($list->status=='1'){{'checked'}}@elseif($list->status=='0'){{''}}@endif>
            </div>
            @endif
        </td>
        <td>
            @if(in_array('users-edit', $authRolePermissions))
                <button data-id="{{ $list->id }}" class="btn btn-warning edit" data-bs-toggle="modal" data-bs-target="#commonModal" title="Edit">
                    <i class="bi bi-pencil-square text-white"></i>
                </button>
            @endif
        </td>
        <td>
            @if(in_array('users-delete', $authRolePermissions))
            <a data-url="{{route('users.destroy')}}" data-id="{{$list->id}}" class="btn btn-danger deleteDataCustom" href="#" class="text-danger" data-bs-toggle="tooltip" data-bs-placement="bottom" title="Delete">
                <i class="bi bi-trash text-white"></i>
            </a>
            @endif
        </td>

    </tr>
    @php $i++; @endphp
    @endforeach
    @else
    <tr>
        <td colspan="5">No Data Found</td>
    </tr>
    @endif
</tbody>
</table>
</div>
<nav class="float-start mt-2">
    <ul class="pagination">
        {!! $Userdata->onEachSide(1)->render('users.pagination') !!}
    </ul>
</nav>
</div>




