1
- <?php namespace GeneaLabs \ LaravelModelCaching ;
1
+ <?php
2
2
3
+ namespace GeneaLabs \LaravelModelCaching ;
4
+
5
+ use BackedEnum ;
3
6
use Exception ;
4
7
use GeneaLabs \LaravelModelCaching \Traits \CachePrefixing ;
5
8
use Illuminate \Database \Query \Expression ;
6
9
use Illuminate \Support \Arr ;
7
10
use Illuminate \Support \Collection ;
8
11
use Illuminate \Support \Str ;
9
12
use Ramsey \Uuid \Uuid ;
13
+ use UnitEnum ;
10
14
11
15
class CacheKey
12
16
{
@@ -80,7 +84,7 @@ protected function getColumnClauses(array $where) : string
80
84
if ($ where ["type " ] !== "Column " ) {
81
85
return "" ;
82
86
}
83
-
87
+
84
88
if ($ where ["first " ] instanceof Expression) {
85
89
$ where ["first " ] = $ this ->expressionToString ($ where ["first " ]);
86
90
}
@@ -179,7 +183,7 @@ protected function getOrderByClauses() : string
179
183
}
180
184
181
185
$ orders = collect ($ this ->query ->orders );
182
-
186
+
183
187
return $ orders
184
188
->reduce (function ($ carry , $ order ) {
185
189
if (($ order ["type " ] ?? "" ) === "Raw " ) {
@@ -225,7 +229,7 @@ protected function getQueryColumns(array $columns) : string
225
229
if (property_exists ($ this ->query , "columns " )
226
230
&& $ this ->query ->columns
227
231
) {
228
- $ columns = array_map (function ($ column ) {
232
+ $ columns = array_map (function ($ column ) {
229
233
return $ this ->expressionToString ($ column );
230
234
}, $ this ->query ->columns );
231
235
@@ -350,7 +354,7 @@ protected function getWhereClauses(array $wheres = []) : string
350
354
return $ value ;
351
355
});
352
356
}
353
-
357
+
354
358
protected function getWheres (array $ wheres ) : Collection
355
359
{
356
360
$ wheres = collect ($ wheres );
@@ -384,7 +388,7 @@ protected function getWithModels() : string
384
388
return "{$ carry }- {$ relatedConnection }: {$ relatedDatabase }: {$ related }" ;
385
389
});
386
390
}
387
-
391
+
388
392
protected function recursiveImplode (array $ items , string $ glue = ", " ) : string
389
393
{
390
394
$ result = "" ;
@@ -411,11 +415,11 @@ protected function recursiveImplode(array $items, string $glue = ",") : string
411
415
return $ result ;
412
416
}
413
417
414
- private function processEnum (\ BackedEnum |\ UnitEnum |Expression |string $ value ): string
418
+ private function processEnum (BackedEnum |UnitEnum |Expression |string | null $ value ): ? string
415
419
{
416
- if ($ value instanceof \ BackedEnum) {
420
+ if ($ value instanceof BackedEnum) {
417
421
return $ value ->value ;
418
- } elseif ($ value instanceof \ UnitEnum) {
422
+ } elseif ($ value instanceof UnitEnum) {
419
423
return $ value ->name ;
420
424
} elseif ($ value instanceof Expression) {
421
425
return $ this ->expressionToString ($ value );
0 commit comments