@php use App\Models\Hodnotenie\HodnotenieEnum; @endphp
<div class="card card-sm shadow">
    <div class="card-header bg-secondary d-flex justify-content-end">
        <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="card-body p-0">
        <div class="table-responsive">
            <table class="table align-items-center mb-0">
                <thead>
                <tr>
                    <th scope="col">#</th>
                    <th scope="col">Hodnotenie</th>
                    <th scope="col">Hodnotil</th>
                    <th scope="col" class="text-center">Vytvorené</th>
                    <th scope="col" class="text-center">Upravené</th>
                </tr>
                </thead>
                <tbody>
                @forelse($hodnotenia as $hodnotenie)
                    <tr class="bg-white">
                        <td>{{ ($hodnotenia->currentPage() * $hodnotenia->perPage()) - $hodnotenia->perPage() + $loop->index + 1 }}
                            .
                        </td>
                        <td class="text-left">
                            <i class="fas fa-thumbs-{{ $hodnotenie->hodnotenie->equals(HodnotenieEnum::kladne()) ? 'up' : 'down' }} text-{{ $hodnotenie->hodnotenie->color() }} @if($hodnotenie->hodnotenie->equals(HodnotenieEnum::neutralne())) fa-rotate-270 @endif"></i>
                        </td>
                        <td class="text-left">
                            <div class="text-black-50"><span class="icon-user"></span>
                                {{ $hodnotenie->hodnotil->cele_meno }} [{{ $hodnotenie->hodnotil->pracovisko->kod }}]
                            </div>
                        </td>
                        <td class="text-center">
                            <span title="{{ $hodnotenie->created_at->format('d.m.Y \o H:i:s') }}">
                                {{ $hodnotenie->created_at->longRelativeDiffForHumans() }}
                            </span>
                        </td>
                        <td class="text-center">
                            <span title="{{ $hodnotenie->updated_at->format('d.m.Y \o H:i:s') }}">
                                {{ $hodnotenie->updated_at->longRelativeDiffForHumans() }}
                            </span>
                        </td>
                    </tr>
                @empty
                    <tr class="bg-light text-center disabled">
                        <td colspan="6">
                            <span class="text-muted h5">Zatiaľ neexistujú žiadne hodnotenia informácie...</span>
                        </td>
                    </tr>
                @endforelse
                </tbody>
            </table>
        </div>
    </div>

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