【常時表示インフォメーション】ページネーション位置変更
All checks were successful
Deploy main / deploy (push) Successful in 21s
All checks were successful
Deploy main / deploy (push) Successful in 21s
This commit is contained in:
parent
06756440ce
commit
c5c35470dc
@ -51,7 +51,7 @@ class InformationController extends Controller
|
|||||||
$q->where('oq.que_status', 3);
|
$q->where('oq.que_status', 3);
|
||||||
} // all は絞り込みなし
|
} // all は絞り込みなし
|
||||||
|
|
||||||
$jobs = $q->orderByDesc('oq.que_id')->paginate(50)->appends($request->query());
|
$jobs = $q->orderBy('oq.que_id')->paginate(20)->appends($request->query());
|
||||||
|
|
||||||
return view('admin.information.list', compact('jobs','period','type','status'));
|
return view('admin.information.list', compact('jobs','period','type','status'));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -121,6 +121,62 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- ページネーション -->
|
||||||
|
@php
|
||||||
|
$paginator = $jobs;
|
||||||
|
$current = $paginator->currentPage();
|
||||||
|
$last = $paginator->lastPage();
|
||||||
|
$query = request()->except('page');
|
||||||
|
$pages = [];
|
||||||
|
if($last <= 20){
|
||||||
|
$pages = range(1,$last);
|
||||||
|
}else{
|
||||||
|
$pages[] = 1;
|
||||||
|
if($current > 4) $pages[] = '...L';
|
||||||
|
$windowStart = max(2, $current - 2);
|
||||||
|
$windowEnd = min($last-1, $current + 2);
|
||||||
|
for($i=$windowStart; $i<=$windowEnd; $i++){
|
||||||
|
$pages[] = $i;
|
||||||
|
}
|
||||||
|
if($current < $last - 3) $pages[] = '...R';
|
||||||
|
$pages[] = $last;
|
||||||
|
}
|
||||||
|
function pageUrl($page,$query){
|
||||||
|
return url()->current() . '?' . http_build_query(array_merge($query,['page'=>$page]));
|
||||||
|
}
|
||||||
|
@endphp
|
||||||
|
@if($last > 1)
|
||||||
|
<div class="d-flex justify-content-end mb-2">
|
||||||
|
<nav aria-label="ページネーション" class="custom-pagination">
|
||||||
|
<ul class="pagination pagination-sm mb-0">
|
||||||
|
<li class="page-item {{ $current==1?'disabled':'' }}">
|
||||||
|
<a class="page-link" href="{{ $current==1?'#':pageUrl(1,$query) }}">‹‹</a>
|
||||||
|
</li>
|
||||||
|
<li class="page-item {{ $current==1?'disabled':'' }}">
|
||||||
|
<a class="page-link" href="{{ $current==1?'#':pageUrl($current-1,$query) }}">‹</a>
|
||||||
|
</li>
|
||||||
|
@foreach($pages as $p)
|
||||||
|
@if(is_string($p) && str_starts_with($p,'...'))
|
||||||
|
<li class="page-item disabled"><span class="page-link">…</span></li>
|
||||||
|
@else
|
||||||
|
<li class="page-item {{ $p==$current?'active':'' }}">
|
||||||
|
<a class="page-link" href="{{ $p==$current?'#':pageUrl($p,$query) }}">{{ $p }}</a>
|
||||||
|
</li>
|
||||||
|
@endif
|
||||||
|
@endforeach
|
||||||
|
<li class="page-item {{ $current==$last?'disabled':'' }}">
|
||||||
|
<a class="page-link" href="{{ $current==$last?'#':pageUrl($current+1,$query) }}">›</a>
|
||||||
|
</li>
|
||||||
|
<li class="page-item {{ $current==$last?'disabled':'' }}">
|
||||||
|
<a class="page-link" href="{{ $current==$last?'#':pageUrl($last,$query) }}">››</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- データテーブル(チェック付き) -->
|
<!-- データテーブル(チェック付き) -->
|
||||||
@ -202,62 +258,7 @@
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- ページネーション -->
|
|
||||||
@php
|
|
||||||
$paginator = $jobs;
|
|
||||||
$current = $paginator->currentPage();
|
|
||||||
$last = $paginator->lastPage();
|
|
||||||
$query = request()->except('page');
|
|
||||||
$pages = [];
|
|
||||||
if($last <= 20){
|
|
||||||
$pages = range(1,$last);
|
|
||||||
}else{
|
|
||||||
$pages[] = 1;
|
|
||||||
if($current > 4) $pages[] = '...L';
|
|
||||||
$windowStart = max(2, $current - 2);
|
|
||||||
$windowEnd = min($last-1, $current + 2);
|
|
||||||
for($i=$windowStart; $i<=$windowEnd; $i++){
|
|
||||||
$pages[] = $i;
|
|
||||||
}
|
|
||||||
if($current < $last - 3) $pages[] = '...R';
|
|
||||||
$pages[] = $last;
|
|
||||||
}
|
|
||||||
function pageUrl($page,$query){
|
|
||||||
return url()->current() . '?' . http_build_query(array_merge($query,['page'=>$page]));
|
|
||||||
}
|
|
||||||
@endphp
|
|
||||||
@if($last > 1)
|
|
||||||
<div class="mt-2 d-flex justify-content-start">
|
|
||||||
<nav aria-label="ページネーション" class="custom-pagination">
|
|
||||||
<ul class="pagination pagination-sm mb-0">
|
|
||||||
<li class="page-item {{ $current==1?'disabled':'' }}">
|
|
||||||
<a class="page-link" href="{{ $current==1?'#':pageUrl(1,$query) }}">‹‹</a>
|
|
||||||
</li>
|
|
||||||
<li class="page-item {{ $current==1?'disabled':'' }}">
|
|
||||||
<a class="page-link" href="{{ $current==1?'#':pageUrl($current-1,$query) }}">‹</a>
|
|
||||||
</li>
|
|
||||||
@foreach($pages as $p)
|
|
||||||
@if(is_string($p) && str_starts_with($p,'...'))
|
|
||||||
<li class="page-item disabled"><span class="page-link">…</span></li>
|
|
||||||
@else
|
|
||||||
<li class="page-item {{ $p==$current?'active':'' }}">
|
|
||||||
<a class="page-link" href="{{ $p==$current?'#':pageUrl($p,$query) }}">{{ $p }}</a>
|
|
||||||
</li>
|
|
||||||
@endif
|
|
||||||
@endforeach
|
|
||||||
<li class="page-item {{ $current==$last?'disabled':'' }}">
|
|
||||||
<a class="page-link" href="{{ $current==$last?'#':pageUrl($current+1,$query) }}">›</a>
|
|
||||||
</li>
|
|
||||||
<li class="page-item {{ $current==$last?'disabled':'' }}">
|
|
||||||
<a class="page-link" href="{{ $current==$last?'#':pageUrl($last,$query) }}">››</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
@endif
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
|
||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user