Total Complexity | 13 |
Total Lines | 85 |
Duplicated Lines | 0 % |
Coverage | 15.38% |
Changes | 0 |
1 | <?php namespace Pz\LaravelDoctrine\Rest\Request; |
||
9 | class IndexRestRequest extends RestRequest implements IndexRequestInterface |
||
10 | { |
||
11 | /** |
||
12 | * @return array |
||
13 | */ |
||
14 | 1 | public function rules() |
|
27 | ]; |
||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @return string |
||
32 | */ |
||
33 | 1 | public function ability() |
|
36 | } |
||
37 | |||
38 | /** |
||
39 | * @return int |
||
40 | */ |
||
41 | public function getStart() |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @return int |
||
48 | */ |
||
49 | public function getLimit() |
||
50 | { |
||
51 | return $this->input('page.limit', 50); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * @return array|null |
||
56 | */ |
||
57 | public function getOrderBy() |
||
58 | { |
||
59 | if ($fields = explode(',', $this->get('sort'))) { |
||
60 | $orderBy = []; |
||
61 | |||
62 | foreach ($fields as $field) { |
||
63 | if (empty($field)) continue; |
||
64 | |||
65 | $direction = 'ASC'; |
||
66 | if ($field[0] === '-') { |
||
67 | $field = substr($field, 1); |
||
68 | $direction = 'DESC'; |
||
69 | } |
||
70 | |||
71 | $orderBy[$field] = $direction; |
||
72 | } |
||
73 | |||
74 | return $orderBy; |
||
75 | } |
||
76 | |||
77 | return null; |
||
78 | } |
||
79 | |||
80 | /** |
||
81 | * @return mixed|null |
||
82 | */ |
||
83 | public function getQuery() |
||
94 | } |
||
95 | } |
||
96 |