@extends('layouts.admin_master')

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


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

<div class="row">
    <div class="col-12">
        <div class="hpanel">
            <!-- <div class="panel-heading">List of Admin Users <br> -->
            <a href="{{url('admin/users/create')}}" class="btn btn-success mb-2 pull-right"><i class="mdi mdi-plus-circle mr-2"></i> Add User</a>
            <div class="clearfix"></div>
            </div>
            <div class="panel-body">
                <div class="table-responsive">
                    <table cellpadding="1" cellspacing="1" class="table table-bordered table-striped" >
                        <thead class="">
                            <tr 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> -->
                                    @else 
                                        @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
                                    @endif
                                </td>

                            </tr>
                            @empty
                                <td>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