@extends('layouts.app')

@section('content')
<div class="container app-content pt-3">
    <h1 class="h3 mb-4">Split Offer Links</h1>
    <div class="py-3">
        <a href="{{ route('admin.split.create') }}" class="btn btn-success"><i class="mr-2 fa fa-plus"></i>Add Split</a>
    </div>
    <div class="card">
        <div class="table-responsive">
            <table class="table card-table table-vcenter">
                <thead class="thead-light">
                    <tr>
                        <th>Name</th>
                        <th>Country Code</th>
                        <th>Link Offer Register</th>
                        <th>Link Offer Play</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach ($splits as $split)
                        <tr>
                            <td>{{ $split->name }}</td>
                            <td>{{ implode(', ', $split->country) }}</td>
                            <td>{{ $split->link_reg }}</td>
                            <td>{{ $split->link_play }}</td>
                            <td>
                                <a href="{{ route('admin.split.edit', $split) }}" class="btn btn-warning btn-sm" type="button">Edit</a>
                                <a href="{{ route('admin.split.destroy', $split) }}" class="btn btn-danger btn-sm"
                                    onclick="event.preventDefault();document.getElementById('delete-{{ $split->id }}').submit();">Delete</a>

                                <form id="delete-{{ $split->id }}" action="{{ route('admin.split.destroy', $split) }}" method="POST" style="display: none;">
                                    @csrf
                                    @method('DELETE')
                                </form>
                            </td>
                        </tr>
                    @endforeach
                </tbody>
            </table>
        </div>

        @if ($splits->hasPages())
            <div class="card-footer">
                {{ $splits->links() }}
            </div>
        @endif

    </div>
</div>
@endsection
