mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-12 06:30:07 +01:00
37 lines
935 B
PHP
37 lines
935 B
PHP
<?php
|
|
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
class NonRetardedSSP {
|
|
public static function run(array $request, Builder $builder) {
|
|
/* 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'];
|
|
|
|
|
|
/* figure out total records */
|
|
$recordsTotal = $builder->count();
|
|
|
|
/* build query */
|
|
$params = [];
|
|
|
|
if ($length != 0) {
|
|
$builder = $builder->limit($length);
|
|
|
|
if ($start != 0) {
|
|
$builder = $builder->offset($start);
|
|
}
|
|
}
|
|
|
|
/* fire it off */
|
|
$data = $builder->get();
|
|
|
|
return [
|
|
'draw' => $draw,
|
|
'recordsTotal' => $recordsTotal,
|
|
'recordsFiltered' => ($recordsTotal - count($data)),
|
|
'data' => $data
|
|
];
|
|
}
|
|
}
|