<div class="tab-pane fade mt-3" id="tab7" role="tabpanel" aria-labelledby="tab7-tab" wire:ignore.self>
    <div class="row">
        <div class="col">
            <div class="card card-primary">
                <div class="card-header">
                    <h3 class="card-title">Allegati</h3>
                </div>
                <div class="card-body">
                    <div class="row">
                        <table class="table table-hover text-nowrap">
                            <thead>
                                <tr>
                                    <th>Nome</th>
                                    <th>Tipologia</th>
                                    <th>Visibile in stampa</th>
                                    <th style="width:100px">&nbsp;</th>
                                    <th style="width:100px">&nbsp;</th>
                                </tr>
                            </thead>
                            <tbody>

                                @foreach ($allegatiImmagini as $allegato)
                                    <tr>
                                        <td>{{ $allegato->name }}</td>
                                        <td>{{ $this->getAllegatoType($allegato->gallery_type) }}
                                        </td>
                                        <td>{{ $allegato->is_visible ? 'SI' : 'NO' }}</td>
                                        @if (!$this->validated)

                                            <td><a wire:click.prevent="editAllegato({{ $allegato->id }})" data-toggle="modal"
                                                    data-target="#allegatiModal" class="btn btn-primary btn-block"
                                                    style="background-color: orange;border-color: orange;"><i
                                                        class="fa fa-edit"></i></i></a></td>
                                            <td><button onclick="confirm('Sei sicuro?') || event.stopImmediatePropagation()"
                                                    wire:click.prevent="removeAllegato({{ $allegato->id }})" type="button"
                                                    class="btn btn-success btn-block"><i class="fa fa-trash"></i>&nbsp;</button>
                                            </td>
                                        @endif
                                    </tr>
                                    @if ($allegato->files != '')
                                        @php
                                            $files = explode('|', $allegato->files);
                                            $chunks = array_chunk($files, 3);
                                        @endphp

                                        @foreach ($chunks as $fileChunk)
                                            <tr>
                                                <td colspan="5" style="border-top:0px solid;">
                                                    @foreach ($fileChunk as $a)
                                                        <a href="{{ url('/storage/' . $a) }}" target="_blank">{{ $a }}</a>&nbsp;&nbsp;&nbsp;
                                                    @endforeach
                                                </td>
                                            </tr>
                                        @endforeach
                                    @endif
                                @endforeach
                            </tbody>
                        </table>
                        @if (!$this->validated)

                            <a class="btn btn-primary " wire:click.prevent="addAllegato(0)" data-toggle="modal"
                                data-target="#allegatiModal">Aggiungi</a>
                        @endif
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
