simplePaginate method

  1. @override
Future<Map<String, dynamic>> simplePaginate([
  1. int perPage = 15,
  2. List<String> columns = const ['*'],
  3. String? pageName,
  4. int? page,
])
override

Implementation

@override
Future<Map<String, dynamic>> simplePaginate([
  int perPage = 15,
  List<String> columns = const ['*'],
  String? pageName,
  int? page,
]) async {
  int currentPage = page ?? 1;
  int total = await count();
  final lastPage = (total / perPage).ceil();
  final offset = (currentPage - 1) * perPage;
  super.take(perPage).skip(offset);
  final pageData = await get();

  return {
    'data': pageData,
    'current_page': currentPage,
    'per_page': perPage,
    'total': total,
    'last_page': lastPage,
  };
}