@extends('layouts.app')
@section('title', 'Bettings')
@section('content')
    <!-- Start Main Content -->
    <x-session-messages />
    <div class="row">
        <div class="col-12">
            <div class="card">
                <div class="card-header">
                    <h4>Bettings</h4>
                    <div class="card-header-form">
                        <x-search-bar route="{{ route('bettings.index') }}" />
                    </div>
                </div>
                <div class="card-body p-0">
                    <div class="row m-1">
                        @foreach ($bettings as $key => $betting)
                            <tr>
                                <td>
                                    <div class="col-4">
                                        <div class="card card-primary">
                                            <div class="card-body">
                                                <div style="height: 250px; overflow: auto;">
                                                    <table class="table table-bordered">
                                                        <thead>
                                                            <h4>Betting id: #{{ $betting->id }}</h4>
                                                        </thead>
                                                        <tbody>
                                                            <tr>
                                                                <td>Game id: #{{ $betting->game->id }}</td>
                                                                <td>Customer Name: {{ $betting->name }}</td>
                                                            </tr>
                                                            <tr>
                                                                <td>Agent Name: {{ $betting->agent->name }}</td>
                                                                <td>Agent phone: {{ $betting->agent->phone }}</td>
                                                            </tr>
                                                            <tr>
                                                                <td>Date: {{ $betting->created_at->format('d-m-y') }}</td>
                                                                <td>Time: {{ $betting->created_at->format('h-i a') }}</td>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                </div>
                                                <div style="height: 250px; overflow: auto;">
                                                    <table class="table table-bordered text-center">
                                                        <thead>
                                                            <tr>
                                                                <th>Numbers</th>
                                                                <th>Amount</th>
                                                                <th>Winnings</th>
                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            @foreach ($betting->details as $bet)
                                                                <tr>
                                                                    <td>{{ $bet->bet_number }}</td>
                                                                    <td>{{ $bet->amount }}</td>
                                                                    <td>{{ $bet->winnings }}</td>
                                                                </tr>
                                                            @endforeach
                                                        </tbody>
                                                        <tfoot>
                                                            <tr>
                                                                <th>Total</th>
                                                                <th><span
                                                                        class="badge badge-primary">{{ $betting->total_amount }}</span>
                                                                </th>
                                                                <th><span
                                                                        class="badge badge-primary">{{ $betting->total_winnings }}</span>
                                                                </th>
                                                            </tr>
                                                        </tfoot>
                                                    </table>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                        @endforeach
                    </div>
                    {{ $bettings->links() }}
                    @unless (filled($bettings))
                        <div class="mx-4 my-4 d-flex justify-content-center">
                            <h5> No games bettings added yet.</h5>
                        </div>
                    @endunless
                </div>
            </div>
        </div>
    </div>
    </div>
    <!-- End Main Content -->

@endsection
