@extends('layouts.admin')

@section('page-title')
    Admin | All Admin Users
@endsection


@section('page-content')
    
<!-- start page title -->
<div class="row">
    <div class="col-12">
        <div class="page-title-box">
            <div class="page-title-right">
                <ol class="breadcrumb m-0">
                    <li class="breadcrumb-item"><a href="{{url('/')}}">Admin</a></li>
                     <li class="breadcrumb-item"><a href="{{url('admin/users')}}">Users</a></li>
                    <li class="breadcrumb-item active">All Users</li>
                </ol>
            </div>
            <h4 class="page-title">Users</h4>
        </div>
    </div>
</div>     
<!-- end page title --> 

{{-- Alert --}}
@include('layouts.alert')

<div class="row">
    <div class="col-12">
        <div class="card">
            <div class="card-body">
                <div class="row mb-2">
                    <div class="col-sm-4">
                        <a href="{{url('admin/users/create')}}" class="btn btn-success mb-2"><i class="mdi mdi-plus-circle mr-2"></i> Add User</a>
                    </div>
                   
                </div>

                <div class="table-responsive">
                    <table class="table table-centered table-borderless table-hover w-100 dt-responsive nowrap" id="products-datatable">
                        <thead class="thead-light">
                            <tr style="color: #000; background-color: #0008ff !important;" class="">
                                <th>Name</th>
                                <th>Email</th>
                                <th>Status</th>
                                <th>Date Created</th>
                                <th >Action</th>
                            </tr>
                        </thead>
                        <tbody>

                            @forelse ($users as $user)
                            <tr class="bg-<?php echo ($user->status == 'disabled') ? 'danger' : ''; ?>" style="color: #000;">
                               
                                <td class="table-user">
                                    <a href="javascript:void(0);" class="text-bodys font-weight-semibold" style="color: #000;">{{ $user->name }}</a>
                                </td>
                                
                                <td>
                                    <span class="font-weight-semibold">{{ $user->email }}</span>
                                </td>

                                <td>
                                    <span class="font-weight-semibold">{{ ucfirst($user->status) }}</span>
                                </td>
                               
                                <td>
                                     {{ Carbon\Carbon::parse($user->created_at)->format('F d, Y') }}
                                </td>
                                <td>
                                    @if ($user->id == Auth::user()->id)
                                        <a href="{{url('admin/users/'.$user->id.'/edit')}}" class="action-icon"> <i class="mdi mdi-square-edit-outline"></i></a>
                                    @endif
                                    @if ($user->status == 'Active')
                                        <a onclick="return confirm('Are you sue you want to disable {{ $user->name }}')" href="{{url('admin/users/disable/'.$user->id)}}" class="action-icon"> <i class="mdi mdi-delete"></i></a>
                                    @endif
                                </td>

                            </tr>
                            @empty
                                <td colspan="5">No Data</td>
                                
                            @endforelse
                           
                            
                        </tbody>
                    </table>

                    {{ $users->links() }}
                </div>
            </div> <!-- end card-body-->
        </div> <!-- end card-->
    </div> <!-- end col -->
</div>
<!-- end row -->

@endsection


@section('page-js')

@endsection