@if (!empty($data['parti_coinvolte']))
    @php
        $vehicles = collect($data['parti_coinvolte'])->filter(function ($item) {
            return $item->conducente_o_pedone == 2;
        });
    @endphp

    @if ($vehicles->count() > 0)
    <style>
        .striped-table {
            width: 100%;
            border-collapse: collapse;
        }

        .striped-table th, .striped-table td {
            border: 1px solid #000;
            padding: 8px;
        }

        .striped-table tr:nth-child(even) {
            background-color: #f2f2f2;
        }

        .striped-table tr:nth-child(odd) {
            background-color: #fff;
        }
    </style>
        <table width="100%" class="table-title">
            <tr>
                <td align="center">
                    <h2>VEICOLI COINVOLTI</h2>
                </td>
            </tr>
        </table>

        <table class="table-content striped-table" width="100%">
            <thead>
                <tr>
                    <th width="33%" align="center">VEICOLO</th>
                    <th width="33%" align="center">TARGA</th>
                    <th width="33%" align="center">CONDUCENTE</th>
                </tr>
            </thead>
            <tbody>
                @foreach ($vehicles as $veicolo)
                    <tr>
                        <td width="33%" align="center">
                            {{ optional(optional($veicolo->veicolo_data)->marca)->name }}
                            {{ optional(optional($veicolo->veicolo_data)->modello)->name }}
                        </td>
                        <td width="33%" align="center">
                            {{ optional($veicolo->veicolo_data)->targa }}
                        </td>
                        <td width="33%" align="center">
                            {{ optional($veicolo->anagrafica_data)->lastname }}
                            {{ optional($veicolo->anagrafica_data)->firstname }}
                        </td>
                    </tr>
                @endforeach
            </tbody>
        </table>
    @endif
@endif
