@extends('layout.master')
@push('plugin-styles')
    <link href="{{ asset('assets/plugins/datatables-net-bs5/dataTables.bootstrap5.css') }}" rel="stylesheet"/>
    <style>
        .editBtn{
            margin-right: 10px;
        }
    </style>
@endpush

@section('content')
    @include('admin.partials.breadcrumb', ['page'=>'Регионы'])
    <div class="row">
        <div class="col-md-12 grid-margin stretch-card">
            <div class="card">
                <div class="card-header d-flex justify-content-between">
                    <h6 class="card-title">Регионы</h6>
                    <a href="{{ route('admin.regions.create') }}" class="btn btn-primary">Создать</a>
                </div>
                <div class="card-body">
                    <div class="table-responsive">
                        <table id="dataTableExample" class="table">
                            <thead>
                            <tr>
                                <th>id Региона</th>
                                <th>id Страны</th>
                                <th>Когда создан</th>
                                <th>Когда обновлен</th>
                                <th>Действия</th>
                            </tr>
                            </thead>
                            <tbody>
                            @foreach ($regions as $region)
                                <tr>
                                    <td>{{ $region->id }}</td>
                                    <td>{{ $region->country_id }}</td>
                                    <td>{{ $region->created_at }}</td>
                                    <td>{{ $region->updated_at }}</td>
                                    <td class="d-flex align-items-center">
                                        <a href="{{ route('admin.regions.edit', $region->id) }}" class="btn btn-success editBtn">
                                            Редактировать
                                        </a>
                                        <form action="{{ route('admin.regions.destroy', $region->id) }}" method="POST">
                                            @csrf
                                            @method('DELETE')
                                            <button type="submit" class="btn btn-danger">Удалить</button>
                                        </form>
                                    </td>
                                </tr>
                            @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection
@push('plugin-scripts')
    <script src="{{ asset('assets/plugins/datatables-net/jquery.dataTables.js') }}"></script>
    <script src="{{ asset('assets/plugins/datatables-net-bs5/dataTables.bootstrap5.js') }}"></script>
@endpush

@push('custom-scripts')
    <script src="{{ asset('assets/js/data-table.js') }}"></script>
@endpush