Pagination
NexaModel documentation.
NexaModel · Storage() · NexaDb
$this->Storage('news')->where()->first();Basic Pagination
// Halaman 1, 10 items per halaman
$users = $this->Storage('users')->paginate(1, 10);
// Halaman 2, 15 items per halaman
$users = $this->Storage('users')->paginate(2, 15);
Pagination dengan Kondisi
$activeUsers = $this->Storage('users')
->where('status', 'active')
->orderBy('created_at', 'DESC')
->paginate(1, 20);
Pagination Info
$paginationInfo = $this->Storage('users')
->paginateInfo(1, 10);
// Result:
// [
// 'current_page' => 1,
// 'per_page' => 10,
// 'total' => 150,
// 'total_pages' => 15,
// 'has_next' => true,
// 'has_prev' => false,
// 'next_page' => 2,
// 'prev_page' => null
// ]
Count Pagination
$countInfo = $this->Storage('users')
->where('status', 'active')
->countPaginate(1, 10);
// Result: ['count' => 150, 'page' => 1, 'per_page' => 10]
Lanjut
Topik sebelumnya: Aggregation dan Statistik. Topik berikutnya: Cache (kompatibilitas API). Lihat juga Models, Events, Helper & template, daftar dokumentasi.