merge(['class' => "flex flex-col gap-2.5 bg-neutral-50 dark:bg-white/1 border border-neutral-200 dark:border-neutral-800 rounded-xl p-2.5 shadow-xs"]) }}
x-data="{
totalQueries: {{ min(count($queries), 100) }},
currentPage: 1,
perPage: 10,
get totalPages() {
return Math.ceil(this.totalQueries / this.perPage);
},
get hasPrevious() {
return this.currentPage > 1;
},
get hasNext() {
return this.currentPage < this.totalPages;
},
goToPage(page) {
if (page >= 1 && page <= this.totalPages) {
this.currentPage = page;
}
},
first() {
this.currentPage = 1;
},
last() {
this.currentPage = this.totalPages;
},
previous() {
if (this.hasPrevious) {
this.currentPage--;
}
},
next() {
if (this.hasNext) {
this.currentPage++;
}
},
get visiblePages() {
const total = this.totalPages;
const current = this.currentPage;
const pages = [];
if (total <= 7) {
for (let i = 1; i <= total; i++) {
pages.push({ type: 'page', value: i });
}
} else {
if (current <= 4) {
for (let i = 1; i <= 5; i++) {
pages.push({ type: 'page', value: i });
}
if (total > 6) {
pages.push({ type: 'ellipsis', value: '...', id: 'end' });
pages.push({ type: 'page', value: total });
}
} else if (current > total - 4) {
pages.push({ type: 'page', value: 1 });
if (total > 6) {
pages.push({ type: 'ellipsis', value: '...', id: 'start' });
}
for (let i = Math.max(total - 4, 2); i <= total; i++) {
pages.push({ type: 'page', value: i });
}
} else {
pages.push({ type: 'page', value: 1 });
pages.push({ type: 'ellipsis', value: '...', id: 'start' });
for (let i = current - 1; i <= current + 1; i++) {
pages.push({ type: 'page', value: i });
}
pages.push({ type: 'ellipsis', value: '...', id: 'end' });
pages.push({ type: 'page', value: total });
}
}
return pages;
}
}"
>
@if (count($queries) > 100)
@endif
@forelse (array_slice($queries, 0, 100) as $index => ['connectionName' => $connectionName, 'sql' => $sql, 'time' => $time])
@empty
@endforelse