@foreach ($users as $user) @endforeach
#ID USER ROLE STATUS ACTIONS
{{ $user->id }}
@php $initials = strtoupper(substr($user->name, 0, 1)); $bgColors = ['#3498db', '#e74c3c', '#2ecc71', '#f39c12', '#9b59b6']; $colorIndex = $user->id % count($bgColors); $bgColor = $bgColors[$colorIndex]; @endphp
{{ $initials }}
{{ $user->name }} {{ $user->email }}
@foreach($user->roles->unique() as $role) {{ $role->name }} @endforeach
@if($user->status == 'active') Active @else Active @endif
@if($users->hasPages())
Hiển thị {{ $users->firstItem() }} đến {{ $users->lastItem() }} trong tổng số {{ $users->total() }} kết quả
@if($users->onFirstPage()) @else @endif @php $currentPage = $users->currentPage(); $lastPage = $users->lastPage(); $onEachSide = 2; // Số trang hiển thị mỗi bên của trang hiện tại // Tính toán phạm vi trang cần hiển thị $windowStart = max(1, $currentPage - $onEachSide); $windowEnd = min($lastPage, $currentPage + $onEachSide); @endphp {{-- Hiển thị trang đầu tiên nếu không nằm trong window --}} @if($windowStart > 1) 1 @if($windowStart > 2) ... @endif @endif {{-- Hiển thị các trang trong window --}} @for($page = $windowStart; $page <= $windowEnd; $page++) @if($page == $currentPage) {{ $page }} @else {{ $page }} @endif @endfor {{-- Hiển thị trang cuối cùng nếu không nằm trong window --}} @if($windowEnd < $lastPage) @if($windowEnd < $lastPage - 1) ... @endif {{ $lastPage }} @endif @if($users->hasMorePages()) @else @endif
@endif