@extends('layouts.app')

@section('content')
<div class="container app-content pt-3">
    <h1 class="h3 mb-4">Languages</h1>
    <div class="py-3">
        <a href="{{ route('admin.language.create') }}" class="btn btn-success"><i class="mr-2 fa fa-plus"></i>Add Language</a>
    </div>
    <div class="card">
        <div class="table-responsive">
            <table class="table table-hover">
                <thead class="thead-light">
                    <tr>
                        <th>Id</th>
                        <th>Locale</th>
                        <th>Name</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach ($languages as $language)
                        <tr>
                            <td>{{ $language->id }}</td>
                            <td>{{ $language->locale }}</td>
                            <td>{{ $language->name }}</td>
                            <td>
                                <a href="{{ route('admin.language.edit', $language) }}" class="btn btn-warning btn-sm" type="button">Edit</a>
                                <a href="{{ route('admin.language.destroy', $language) }}" class="btn btn-danger btn-sm"
                                    onclick="event.preventDefault();document.getElementById('delete-{{ $language->id }}').submit();">Delete</a>

                                <form id="delete-{{ $language->id }}" action="{{ route('admin.language.destroy', $language) }}" method="POST" style="display: none;">
                                    @csrf
                                    @method('DELETE')
                                </form>
                            </td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        </div>
        @if ($languages->hasPages())
            <div class="card-footer">
                {{ $languages->links() }}
            </div>
        @endif
    </div>
</div>
@endsection
