@@ -13,8 +13,8 @@ class CacheKey
13
13
protected function getCachePrefix () : string
14
14
{
15
15
return "genealabs:laravel-model-caching: "
16
- . (config (' laravel-model-caching.cache-prefix ' )
17
- ? config (' laravel-model-caching.cache-prefix ' , '' ) . ": "
16
+ . (config (" laravel-model-caching.cache-prefix " )
17
+ ? config (" laravel-model-caching.cache-prefix " , "" ) . ": "
18
18
: "" );
19
19
}
20
20
@@ -29,13 +29,13 @@ public function __construct(
29
29
}
30
30
31
31
public function make (
32
- array $ columns = [' * ' ],
32
+ array $ columns = [" * " ],
33
33
$ idColumn = null ,
34
- string $ keyDifferentiator = ''
34
+ string $ keyDifferentiator = ""
35
35
) : string {
36
36
$ key = $ this ->getCachePrefix ();
37
37
$ key .= $ this ->getModelSlug ();
38
- $ key .= $ this ->getIdColumn ($ idColumn ?: '' );
38
+ $ key .= $ this ->getIdColumn ($ idColumn ?: "" );
39
39
$ key .= $ this ->getQueryColumns ($ columns );
40
40
$ key .= $ this ->getWhereClauses ();
41
41
$ key .= $ this ->getWithModels ();
@@ -49,13 +49,13 @@ public function make(
49
49
50
50
protected function getIdColumn (string $ idColumn ) : string
51
51
{
52
- return $ idColumn ? "_ {$ idColumn }" : '' ;
52
+ return $ idColumn ? "_ {$ idColumn }" : "" ;
53
53
}
54
54
55
55
protected function getLimitClause () : string
56
56
{
57
57
if (! $ this ->query ->limit ) {
58
- return '' ;
58
+ return "" ;
59
59
}
60
60
61
61
return "-limit_ {$ this ->query ->limit }" ;
@@ -69,7 +69,7 @@ protected function getModelSlug() : string
69
69
protected function getOffsetClause () : string
70
70
{
71
71
if (! $ this ->query ->offset ) {
72
- return '' ;
72
+ return "" ;
73
73
}
74
74
75
75
return "-offset_ {$ this ->query ->offset }" ;
@@ -81,48 +81,48 @@ protected function getOrderByClauses() : string
81
81
82
82
return $ orders
83
83
->reduce (function ($ carry , $ order ) {
84
- if (($ order [' type ' ] ?? '' ) === ' Raw ' ) {
85
- return $ carry . ' _orderByRaw_ ' . str_slug ($ order [' sql ' ]);
84
+ if (($ order [" type " ] ?? "" ) === " Raw " ) {
85
+ return $ carry . " _orderByRaw_ " . str_slug ($ order [" sql " ]);
86
86
}
87
87
88
- return $ carry . ' _orderBy_ ' . $ order [' column ' ] . ' _ ' . $ order [' direction ' ];
88
+ return $ carry . " _orderBy_ " . $ order [" column " ] . " _ " . $ order [" direction " ];
89
89
})
90
- ?: '' ;
90
+ ?: "" ;
91
91
}
92
92
93
93
protected function getQueryColumns (array $ columns ) : string
94
94
{
95
- if ($ columns === [' * ' ] || $ columns === []) {
96
- return '' ;
95
+ if ($ columns === [" * " ] || $ columns === []) {
96
+ return "" ;
97
97
}
98
98
99
- return ' _ ' . implode (' _ ' , $ columns );
99
+ return " _ " . implode (" _ " , $ columns );
100
100
}
101
101
102
102
protected function getTypeClause ($ where ) : string
103
103
{
104
- $ type =in_array ($ where [' type ' ], [' In ' , ' NotIn ' , ' Null ' , ' NotNull ' , ' between ' ])
105
- ? strtolower ($ where [' type ' ])
106
- : strtolower ($ where [' operator ' ]);
104
+ $ type =in_array ($ where [" type " ], [" In " , " NotIn " , " Null " , " NotNull " , " between " ])
105
+ ? strtolower ($ where [" type " ])
106
+ : strtolower ($ where [" operator " ]);
107
107
108
- return str_replace (' ' , ' _ ' , $ type );
108
+ return str_replace (" " , " _ " , $ type );
109
109
}
110
110
111
111
protected function getValuesClause (array $ where = null ) : string
112
112
{
113
- if (in_array ($ where [' type ' ], [' NotNull ' ])) {
114
- return '' ;
113
+ if (in_array ($ where [" type " ], [" NotNull " ])) {
114
+ return "" ;
115
115
}
116
116
117
- $ values = is_array (array_get ($ where , ' values ' ))
118
- ? implode (' _ ' , $ where [' values ' ])
119
- : '' ;
117
+ $ values = is_array (array_get ($ where , " values " ))
118
+ ? implode (" _ " , $ where [" values " ])
119
+ : "" ;
120
120
121
- if (! $ values && $ this ->query ->bindings [' where ' ] ?? false ) {
122
- $ values = implode (' _ ' , $ this ->query ->bindings [' where ' ]);
121
+ if (! $ values && $ this ->query ->bindings [" where " ] ?? false ) {
122
+ $ values = implode (" _ " , $ this ->query ->bindings [" where " ]);
123
123
}
124
124
125
- return ' _ ' . $ values ;
125
+ return " _ " . $ values ;
126
126
}
127
127
128
128
protected function getWhereClauses (array $ wheres = []) : string
@@ -136,46 +136,46 @@ protected function getWhereClauses(array $wheres = []) : string
136
136
137
137
return $ value ;
138
138
})
139
- . '' ;
139
+ . "" ;
140
140
}
141
141
142
142
protected function getNestedClauses (array $ where ) : string
143
143
{
144
- if (! in_array ($ where [' type ' ], [' Exists ' , ' Nested ' , ' NotExists ' ])) {
145
- return '' ;
144
+ if (! in_array ($ where [" type " ], [" Exists " , " Nested " , " NotExists " ])) {
145
+ return "" ;
146
146
}
147
147
148
- return ' _ ' . strtolower ($ where [' type ' ]) . $ this ->getWhereClauses ($ where [' query ' ]->wheres );
148
+ return " _ " . strtolower ($ where [" type " ]) . $ this ->getWhereClauses ($ where [" query " ]->wheres );
149
149
}
150
150
151
151
protected function getColumnClauses (array $ where ) : string
152
152
{
153
- if ($ where [' type ' ] !== ' Column ' ) {
154
- return '' ;
153
+ if ($ where [" type " ] !== " Column " ) {
154
+ return "" ;
155
155
}
156
156
157
- return "_ {$ where [' boolean ' ]}_ {$ where [' first ' ]}_ {$ where [' operator ' ]}_ {$ where [' second ' ]}" ;
157
+ return "_ {$ where [" boolean " ]}_ {$ where [" first " ]}_ {$ where [" operator " ]}_ {$ where [" second " ]}" ;
158
158
}
159
159
160
160
protected function getRawClauses (array $ where ) : string
161
161
{
162
- if ($ where [' type ' ] !== ' raw ' ) {
163
- return '' ;
162
+ if ($ where [" type " ] !== " raw " ) {
163
+ return "" ;
164
164
}
165
165
166
- return "_ {$ where [' boolean ' ]}_ " . str_slug ($ where [' sql ' ]);
166
+ return "_ {$ where [" boolean " ]}_ " . str_slug ($ where [" sql " ]);
167
167
}
168
168
169
169
protected function getOtherClauses (array $ where , string $ carry = null ) : string
170
170
{
171
- if (in_array ($ where [' type ' ], [' Exists ' , ' Nested ' , ' NotExists ' , ' raw ' , ' Column ' ])) {
172
- return '' ;
171
+ if (in_array ($ where [" type " ], [" Exists " , " Nested " , " NotExists " , " raw " , " Column " ])) {
172
+ return "" ;
173
173
}
174
174
175
175
$ value = $ this ->getTypeClause ($ where );
176
176
$ value .= $ this ->getValuesClause ($ where );
177
177
178
- return "{$ carry }- {$ where [' column ' ]}_ {$ value }" ;
178
+ return "{$ carry }- {$ where [" column " ]}_ {$ value }" ;
179
179
}
180
180
181
181
protected function getWheres (array $ wheres ) : Collection
@@ -194,9 +194,9 @@ protected function getWithModels() : string
194
194
$ eagerLoads = collect ($ this ->eagerLoad );
195
195
196
196
if ($ eagerLoads ->isEmpty ()) {
197
- return '' ;
197
+ return "" ;
198
198
}
199
199
200
- return ' - ' . implode (' - ' , $ eagerLoads ->keys ()->toArray ());
200
+ return " - " . implode (" - " , $ eagerLoads ->keys ()->toArray ());
201
201
}
202
202
}
0 commit comments