@extends('admin.layouts.app')
@section('panel')
    <div class="row">
        <div class="col-lg-12">
            <div class="card b-radius--10 ">
                <div class="card-body p-0">
                    <div class="table-responsive--md  table-responsive">
                        <table class="table table--light style--two">
                            <thead>
                            <tr>
                                <th>@lang('Client')</th>  
                                <th>@lang('Total Service')</th>
                                <th>@lang('Total Domain')</th>
                                <th>@lang('Email-Phone')</th>
                                <th>@lang('Country')</th>
                                <th>@lang('Joined At')</th>
                                <th>@lang('Balance')</th>
                                <th>@lang('Action')</th>
                            </tr> 
                            </thead>
                            <tbody> 
                            @forelse($users as $user)
                            <tr> 
                                <td>
                                    <span class="fw-bold">{{$user->fullname}}</span>
                                    <br>
                                    <span class="small">
                                        <a href="{{ permit('admin.users.detail') ? route('admin.users.detail', $user->id) : 'javascript:void(0)' }}">
                                            <span>@</span>{{ $user->username }}
                                        </a>
                                    </span>
                                </td>

                                <td>
                                    <a class="fw-bold" href="{{ permit('admin.users.services') ? route('admin.users.services', $user->id) : 'javascript:void(0)' }}">
                                        {{ $user->hostings->count() }}
                                    </a>
                                </td>

                                <td>
                                    <a class="fw-bold" href="{{ permit('admin.users.domains') ? route('admin.users.domains', $user->id) : 'javascript:void(0)' }}">
                                        {{ $user->domains->count() }}
                                    </a>
                                </td>

                                <td>
                                    {{ $user->email }}<br>{{ $user->mobile }}
                                </td>
                                <td>
                                    <span class="fw-bold" title="{{ @$user->address->country }}">{{ $user->country_code }}</span>
                                </td>



                                <td>
                                    {{ showDateTime($user->created_at) }} <br> {{ diffForHumans($user->created_at) }}
                                </td>


                                <td>
                                    <span class="fw-bold">

                                    {{ $general->cur_sym }}{{ showAmount($user->balance) }}
                                    </span>
                                </td>

                                <td>
                                    <div class="button--group">
                                        @permit('admin.users.detail')
                                            <a href="{{ route('admin.users.detail', $user->id) }}" class="btn btn-sm btn-outline--primary">
                                                <i class="las la-desktop"></i> @lang('Details')
                                            </a>
                                        @else 
                                            <button class="btn btn-sm btn-outline--primary" disabled>
                                                <i class="las la-desktop"></i> @lang('Details')
                                            </button>
                                        @endpermit
                                        @if (request()->routeIs('admin.users.kyc.pending'))
                                            @permit('admin.users.kyc.details')
                                                <a href="{{ route('admin.users.kyc.details', $user->id) }}" class="btn btn-sm btn-outline--dark" target="_blank">
                                                    <i class="las la-user-check"></i>@lang('KYC Data')
                                                </a>
                                            @else 
                                                <button class="btn btn-sm btn-outline--dark" disabled>
                                                    <i class="las la-user-check"></i>@lang('KYC Data')
                                                </button>
                                            @endpermit
                                        @endif
                                    </div>
                                </td>

                            </tr>
                            @empty
                                <tr>
                                    <td class="text-muted text-center" colspan="100%">{{ __($emptyMessage) }}</td>
                                </tr>
                            @endforelse

                            </tbody>
                        </table><!-- table end -->
                    </div>
                </div>
                @if ($users->hasPages())
                <div class="card-footer py-4">
                    {{ paginateLinks($users) }}
                </div>
                @endif
            </div>
        </div>


    </div>
@endsection



@push('breadcrumb-plugins')
<x-search-form placeholder="Username / Email" />
    @permit('admin.users.add.new.form')
        <a href="{{ route('admin.users.add.new.form') }}" class="btn btn-outline--primary h-45">
            <i class="las la-plus"></i>@lang('Add New')
        </a>
    @endpermit
@endpush
