@extends('tablar::page')

@section('content')
<div class="page-header d-print-none">
    <div class="container-xl">
        <div class="row g-2 align-items-center">
            <div class="col">
                <h2 class="page-title">Judging Entry</h2>
            </div>
        </div>
    </div>
</div>
<div class="page-body">
    <div class="container-xl">
        <div class="row row-cards">
            <div class="col-12">
                <div class="card">
                    <div class="card-body">
                        <form method="POST" action="/judgingentry" class="row g-3">
                            {{ csrf_field() }}
                            <div class="col-md-4">
                                <label for="judge_id" class="form-label">Judge</label>
                                <select name="judgenum" id="judge_id" class="form-select" required>
                                    <option value="">Select Judge</option>
                                    @foreach(\App\Models\Judges::all() as $judge)
                                        <option value="{{ $judge->id }}">{{ $judge->judge_number }}</option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="col-md-4">
                                <label for="vehicle_id" class="form-label">Vehicle</label>
                                <select name="vehnum" id="vehicle_id" class="form-select" required>
                                    <option value="">Select Vehicle</option>
                                    @foreach(\App\Models\Vehicles::with('vehicleOwner')->get()->sortBy(function($v){ return (int)($v->vehicleOwner->bidder_assigned_number ?? 0); }) as $vehicle)
                                        <option value="{{ $vehicle->id }}">
                                            {{ $vehicle->vehicleOwner->bidder_assigned_number ?? '?' }} - {{ $vehicle->make }} {{ $vehicle->model }}
                                        </option>
                                    @endforeach
                                </select>
                            </div>
                            <div class="col-md-4">
                                <label for="score" class="form-label">Score</label>
                                <input type="text" name="score" id="score" class="form-control" required>
                            </div>
                            <div class="col-12">
                                <button type="submit" class="btn btn-primary">Submit Score</button>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
@endsection

@include('components.tomselect')
