1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Sfneal\Tracking\Builders; |
4
|
|
|
|
5
|
|
|
use Sfneal\Builders\QueryBuilder; |
6
|
|
|
use Sfneal\Users\Builders\Interfaces\WhereUserInterface; |
7
|
|
|
use Sfneal\Users\Builders\Traits\WhereUser; |
8
|
|
|
|
9
|
|
|
class TrackTrafficBuilder extends QueryBuilder implements WhereUserInterface |
10
|
|
|
{ |
11
|
|
|
use WhereUser; |
12
|
|
|
|
13
|
|
|
/** |
14
|
|
|
* Scope query results to Traffic sent to a particular endpoint $uri. |
15
|
|
|
* |
16
|
|
|
* @param string $uri |
17
|
|
|
* @param string $operator |
18
|
|
|
* @param string $boolean |
19
|
|
|
* |
20
|
|
|
* @return $this |
21
|
|
|
*/ |
22
|
|
|
public function whereRequestUri(string $uri, string $operator = '=', string $boolean = 'and') |
23
|
|
|
{ |
24
|
|
|
$this->where('request_uri', $operator, $uri, $boolean); |
25
|
|
|
|
26
|
|
|
return $this; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Add an 'or where' request_uri clause to the query. |
31
|
|
|
* |
32
|
|
|
* @param string $uri |
33
|
|
|
* @param string $operator |
34
|
|
|
* |
35
|
|
|
* @return $this |
36
|
|
|
*/ |
37
|
|
|
public function orWhereRequestUri(string $uri, string $operator = '=') |
38
|
|
|
{ |
39
|
|
|
$this->whereRequestUri($uri, $operator, 'or'); |
40
|
|
|
|
41
|
|
|
return $this; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Scope query results to Traffic sent to an array of $uris. |
46
|
|
|
* |
47
|
|
|
* @param array $uris |
48
|
|
|
* @param string $boolean |
49
|
|
|
* @param bool $not |
50
|
|
|
* |
51
|
|
|
* @return $this |
52
|
|
|
*/ |
53
|
|
|
public function whereRequestUriIn(array $uris, string $boolean = 'and', bool $not = false) |
54
|
|
|
{ |
55
|
|
|
$this->whereIn('request_uri', $uris, $boolean, $not); |
|
|
|
|
56
|
|
|
|
57
|
|
|
return $this; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* Add a where clause that scopes query results to Traffic originating in a particular app environment. |
62
|
|
|
* |
63
|
|
|
* @param string $environment |
64
|
|
|
* @param string $operator |
65
|
|
|
* @param string $boolean |
66
|
|
|
* |
67
|
|
|
* @return $this |
68
|
|
|
*/ |
69
|
|
|
public function whereEnvironment(string $environment, string $operator = '=', string $boolean = 'and') |
70
|
|
|
{ |
71
|
|
|
$this->where('app_environment', $operator, $environment, $boolean); |
72
|
|
|
|
73
|
|
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* Scope query results to only Traffic originating from a 'production' environment. |
78
|
|
|
* |
79
|
|
|
* @return $this |
80
|
|
|
*/ |
81
|
|
|
public function whereEnvironmentProduction() |
82
|
|
|
{ |
83
|
|
|
$this->whereEnvironment('production'); |
84
|
|
|
|
85
|
|
|
return $this; |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* Scope query results to only Traffic originating from a 'development' environment. |
90
|
|
|
* |
91
|
|
|
* @return $this |
92
|
|
|
*/ |
93
|
|
|
public function whereEnvironmentDevelopment() |
94
|
|
|
{ |
95
|
|
|
$this->whereEnvironment('development'); |
96
|
|
|
|
97
|
|
|
return $this; |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|