-
Notifications
You must be signed in to change notification settings - Fork 0
Pagination
Tirapong Chaiyakun edited this page Sep 19, 2026
·
1 revision
รองรับ ?page=1&per_page=15
per_page สูงสุด 100
public function index(): never
{
$this->paginate(\App\Models\User::class);
}
public function active(): never
{
$this->paginate(\App\Models\User::class, ['status' => 'active']);
}$where เป็นการเทียบค่าตรงกัน ไม่ใช่ค้นข้อความ ?q=
[$page, $perPage] = \Core\Paginator::fromRequest($this->request);
$result = \App\Models\User::paginate($page, $perPage);
\Core\Response::paginate($result['data'], $result['total'], $page, $perPage);{
"meta": {
"pagination": {
"total": 23,
"per_page": 10,
"current_page": 2,
"last_page": 3,
"from": 11,
"to": 20
}
}
}ถ้าไม่มีแถว from และ to เป็น 0