Laravel Pagination

Eloquent Example

$honor = AchievementM::wherenotNull('id')
                ->orderBy('sort_order', 'asc')
                ->paginate(1);

HTML

@php
	$class = '';
	if($honor->onFirstPage() == true){
		$class = '-disable';
	}
@endphp
<a href="{{ $honor->previousPageUrl() }}" class="btn -btn-lg {{ $class }}">上一頁</a>

@php
	$class = '';
	if($honor->hasMorePages() == false){
		$class = '-disable';
	}
@endphp
<a href="{{ $honor->nextPageUrl() }}" class="btn -btn-lg {{ $class }}">下一頁</a>

Common Functions

lastPage();
//Number of last page
count(); //Item count of this page
total(); //Item count of all items
currentPage();
lastPage();
previousPageUrl()
nextPageUrl()
onFirstPage()
hasMorePages()
hasPages()
perPage()
 //Page size
items()

Reference: