@php use App\Models\Hodnotenie\HodnotenieEnum; @endphp
<section>
    <div class="container">
        <div class="row">
            <div class="col-12">
                @if($informacie->isEmpty())
                    <div class="alert alert-primary text-small">
                        <i class="icon-info mr-2"></i>
                        Zatiaľ neexistujú žiadne informácie pre používateľov...
                    </div>
                @else
                    <div class="card card-sm shadow">
                        <div class="card-header bg-secondary d-flex justify-content-between">
                            <div></div>
                            <form class="d-flex align-items-center">
                                <span class="mr-2 text-muted text-small text-nowrap">Zoradiť:</span>
                                <select class="custom-select" wire:model="sort">
                                    <option value="1">od najstarších</option>
                                    <option value="0">od najnovších</option>
                                </select>
                            </form>
                        </div>
                        <div class="list-group list-group-flush">
                            @foreach($informacie as $informacia)
                                <a class="list-group-item"
                                   href="{{ route('portal.informacie.show', $informacia) }}">
                                    <div class="media item-align-center">
                                        <div class="media-body">
                                            <div class="d-flex justify-content-between mb-1">
                                                <div>
                                                    <h3 class="h4">{{ $informacia->titulok }}</h3>
                                                </div>
                                                @if($informacia->odporucane)
                                                    <div>
                                                        <div class="badge badge-success">ODPORÚČANÉ</div>
                                                    </div>
                                                @endif
                                            </div>
                                            <div class="d-flex justify-content-between">
                                                <p class="h6 mb-1">{{ $informacia->uvod }}</p>
                                                <ul class="list-inline text-muted d-flex justify-content-between">
                                                    <li class="list-inline-item">
                                                        <span class="icon-thumbs-up"></span>
                                                        {{ $informacia->pocetHodnoteniPodlaDruhu(HodnotenieEnum::kladne()) }}
                                                    </li>
                                                    <li class="list-inline-item">
                                                        <span class="icon-thumbs-down"></span>
                                                        {{ $informacia->pocetHodnoteniPodlaDruhu(HodnotenieEnum::zaporne()) }}
                                                    </li>
                                                </ul>
                                            </div>
                                            <div class="text-small">
                                                <ul class="list-inline text-muted d-flex justify-content-between">
                                                    <li class="list-inline-item">
                                                        <span class="icon-user"></span>
                                                        {{ $informacia->vytvoril->cele_meno }}
                                                    </li>
                                                    @if(is_null($informacia->cas_zverejnenia))
                                                        <li>-</li>
                                                    @else
                                                        <li class="list-inline-item"
                                                            title="{{ $informacia->cas_zverejnenia->format('d.m.Y \o H:i') }}">
                                                            <span class="icon-calendar"></span>
                                                            {{ $informacia->cas_zverejnenia->longRelativeDiffForHumans() }}
                                                        </li>
                                                    @endif
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </a>
                            @endforeach
                        </div>

                        <div class="card-footer bg-secondary d-flex justify-content-between align-items-center">
                            @if(!$informacie->isEmpty() && $informacie->hasPages())
                                {{ $informacie->onEachSide(5)->links() }}
                            @endif
                            <div>
                                    <span class="text-muted text-small">Počet položiek {{ ($informacie->currentPage() * $informacie->perPage()) - $informacie->perPage() + 1 }} - @if($informacie->total() > ($informacie->currentPage() * $informacie->perPage()))
                                            {{ $informacie->currentPage() * $informacie->perPage() }}
                                        @else
                                            {{ $informacie->total() }}
                                        @endif z {{ $informacie->total() }}</span>
                            </div>
                        </div>
                    </div>
                @endif
            </div>
        </div>
    </div>
</section>