-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
Copy pathOperatable.php
50 lines (45 loc) · 1.01 KB
/
Operatable.php
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
<?php
namespace Lomkit\Rest\Concerns\Resource;
use Lomkit\Rest\Http\Requests\RestRequest;
trait Operatable
{
/**
* The calculated operators if already done in this request.
*
* @var array
*/
protected array $calculatedOperators;
/**
* The operators that could be provided.
*
* @param RestRequest $request
*
* @return array
*/
public function operators(RestRequest $request): array
{
return [
'=',
'!=',
'>',
'>=',
'<',
'<=',
'like',
'not like',
'in',
'not in',
];
}
/**
* Get the resource's operators.
*
* @param \Lomkit\Rest\Http\Requests\RestRequest $request
*
* @return array
*/
public function getOperators(\Lomkit\Rest\Http\Requests\RestRequest $request): array
{
return $this->calculatedOperators ?? ($this->calculatedOperators = $this->operators($request));
}
}