ponepaste/includes/NonRetardedSSP.class.php

38 lines
935 B
PHP
Raw Normal View History

2021-08-16 11:52:30 -04:00
<?php
2021-08-22 22:05:26 -04:00
2021-09-02 08:55:14 -04:00
use Illuminate\Database\Eloquent\Builder;
2021-08-16 11:52:30 -04:00
class NonRetardedSSP {
2022-03-12 13:56:32 -05:00
public static function run(array $request, Builder $builder) {
2021-08-17 13:09:08 -04:00
/* Some of these parameters might not be passed; zero is an OK default */
$draw = (int) @$request['draw'];
$start = (int) @$request['start'];
$length = (int) @$request['length'];
2021-08-16 11:52:30 -04:00
2021-09-02 08:55:14 -04:00
2021-08-17 13:09:08 -04:00
/* figure out total records */
2021-09-02 08:55:14 -04:00
$recordsTotal = $builder->count();
2021-08-17 13:09:08 -04:00
/* build query */
$params = [];
if ($length != 0) {
2021-09-02 08:55:14 -04:00
$builder = $builder->limit($length);
2021-08-17 13:09:08 -04:00
if ($start != 0) {
2021-09-02 08:55:14 -04:00
$builder = $builder->offset($start);
2021-08-17 13:09:08 -04:00
}
}
/* fire it off */
2021-09-02 08:55:14 -04:00
$data = $builder->get();
2021-08-17 13:09:08 -04:00
return [
'draw' => $draw,
'recordsTotal' => $recordsTotal,
'recordsFiltered' => ($recordsTotal - count($data)),
'data' => $data
];
}
}