-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDataTableResults.php
More file actions
96 lines (84 loc) · 2.28 KB
/
DataTableResults.php
File metadata and controls
96 lines (84 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/*
* This file is part of the Gesdinet MetronicDataTableBundle package.
*
* (c) Gesdinet <marcos@gesdinet.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Gesdinet\MetronicDataTableBundle;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Data to return to DataTables plugin.
*
* @see https://keenthemes.com/metronic/documentation.html#sec14
*
* @property int $page Page number, before filtering.
* @property int $pages Total pages, before filtering.
* @property int $perpage Total records per page, before filtering.
* @property int $total Total records, before filtering.
* @property string $sort Sort direction, before filtering.
* @property string $field Sort field, before filtering.
* @property array $data The data to be displayed in the table.
*/
class DataTableResults implements \JsonSerializable
{
/**
* @Assert\NotNull
* @Assert\GreaterThanOrEqual(value="0")
*/
public $page = 0;
/**
* @Assert\NotNull
* @Assert\GreaterThanOrEqual(value="0")
*/
public $pages = 0;
/**
* @Assert\NotNull
* @Assert\GreaterThanOrEqual(value="0")
*/
public $perpage = 0;
/**
* @Assert\NotNull
* @Assert\GreaterThanOrEqual(value="0")
*/
public $total = 0;
/**
* @Assert\NotNull
* @Assert\Choice(choices={"asc", "desc"}, strict=true)
*/
public $sort = 'asc';
/**
* @Assert\NotNull
*/
public $field = '';
/**
* @Assert\NotNull
* @Assert\Type(type="array")
*/
public $data = [];
/**
* @Assert\NotNull
* @Assert\Type(type="array")
*/
public $totalDataRow = [];
/**
* Convert results into array as expected by DataTables plugin.
*/
public function jsonSerialize(): array
{
return [
'meta' => [
'page' => $this->page,
'pages' => $this->pages,
'perpage' => $this->perpage,
'total' => $this->total,
'sort' => $this->sort,
'field' => $this->field,
],
'data' => $this->data,
'totalDataRow' => $this->totalDataRow,
];
}
}