@extends('Admin.master_page')


@section('title')
    <h5 class="m-0 font-weight-bold text-primary" style="float: left;">Admins</h5>

    <a href="{{ route('admin-account.create') }}" style="float: right;"><i class="fas fa-plus-circle"></i></a>
@endsection

@section('content')
    <div class="table-responsive">


        @include('Admin.Admin._filter')


        <br>
        <br>
        <br>


        <div class="container">
            <div class="row">


                @forelse($admins as $key => $user)
                    <div class="col-sm col-lg-6 mb-4">
                        <div class="card">
                            <div class="card-header">
                                User {{ $key + $admins->firstItem() }}
                            </div>
                            <div class="card-body">
                                <table class="table" style="border:none">
                                    <tr>
                                        <th>Name</th>
                                        <td>
                                            <div style="text-align: center">
                                                {{ $user->name }} <br>
                                            </div>
                                        </td>
                                    </tr>
                                    <tr>
                                        <th>Email</th>
                                        <td>
                                            <div style="text-align: center">
                                                {{ $user->email }}
                                            </div>
                                        </td>
                                    </tr>
                                </table>

                                <form action="{{ route('admin-account.destroy', $user->id) }}" method="post"
                                    id="form-{{ $user->id }}">
                                    {{ csrf_field() }}
                                    {{ method_field('DELETE') }}
                                </form>

                                <a href="{{ route('admin-account.edit', $user->id) }}" class="btn btn-sm btn-success"><i
                                        class="fas fa-edit"></i></a>
                                &nbsp;
                                <a href=""
                                    onclick="if(confirm('Are you sure to delete?')) {
                               event.preventDefault();
                               document.getElementById('form-{{ $user->id }}').submit();
                               }else{ event.preventDefault(); }"
                                    class="btn btn-sm btn-danger"><i class="fas fa-trash-alt"></i></a>
                            </div>
                        </div>


                    </div>
                @empty
                @endforelse


            </div>

            <br>
            <br>
            <div class="container">
                <div class="row justify-content-center">
                    @if (isset($_GET['search']) and $_GET['search'] != null)
                        {{ $admins->appends(['search' => $_GET['search']])->links() }}
                    @else
                        {{ $admins->links() }}
                    @endif

                </div>
            </div>

            <br>
            <br>
            <br>
        </div>

    </div>
@endsection
