Passed
Push — master ( 397338...b5049f )
by Mohammad
03:52
created
src/Utility/AbstractRepository.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -115,17 +115,17 @@  discard block
 block discarded – undo
115 115
         if (isset($criteria['search'])) {
116 116
             foreach ($this->model->searchable as $method => $columns) {
117 117
                 if (method_exists($this->model, $method)) {
118
-                    $latest->orWhereHas($method, function ($query) use ($criteria, $columns) {
118
+                    $latest->orWhereHas($method, function($query) use ($criteria, $columns) {
119 119
                         /* @var $query Builder */
120
-                        $query->where(function ($query2) use ($criteria, $columns) {
120
+                        $query->where(function($query2) use ($criteria, $columns) {
121 121
                             /* @var $query2 Builder */
122 122
                             foreach ((array) $columns as $column) {
123
-                                $query2->orWhere($column, 'like', '%'.$criteria['search'].'%');
123
+                                $query2->orWhere($column, 'like', '%' . $criteria['search'] . '%');
124 124
                             }
125 125
                         });
126 126
                     });
127 127
                 } else {
128
-                    $latest->orWhere($columns, 'like', '%'.$criteria['search'].'%');
128
+                    $latest->orWhere($columns, 'like', '%' . $criteria['search'] . '%');
129 129
                 }
130 130
             }
131 131
         }
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
      */
257 257
     public function find($entityId = 0, $columns = ['*'])
258 258
     {
259
-        if($this->allowCaching)
259
+        if ($this->allowCaching)
260 260
         {
261 261
             if (isset($this->cache[$entityId]))
262 262
                 return $this->cache[$entityId];
@@ -264,7 +264,7 @@  discard block
 block discarded – undo
264 264
 
265 265
         $entity = $this->model->with($this->with)->find($entityId, $columns);
266 266
 
267
-        if($this->allowCaching)
267
+        if ($this->allowCaching)
268 268
             $this->cache[$entityId] = $entity;
269 269
 
270 270
         return $entity;
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
      */
281 281
     public function findOrFail($entityId = 0, $columns = ['*'])
282 282
     {
283
-        if($this->allowCaching)
283
+        if ($this->allowCaching)
284 284
         {
285 285
             if (isset($this->cache[$entityId]))
286 286
                 return $this->cache[$entityId];
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 
289 289
         $entity = $this->model->with($this->with)->findOrFail($entityId, $columns);
290 290
 
291
-        if($this->allowCaching)
291
+        if ($this->allowCaching)
292 292
             $this->cache[$entityId] = $entity;
293 293
 
294 294
         return $entity;
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
      */
303 303
     public function first($filter = [], $columns = ['*'])
304 304
     {
305
-        if($this->allowCaching)
305
+        if ($this->allowCaching)
306 306
         {
307 307
             if (isset($this->cache['first']))
308 308
                 return $this->cache['first'];
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 
311 311
         $entity = $this->model->with($this->with)->select($columns)->where($filter)->first();
312 312
 
313
-        if($this->allowCaching)
313
+        if ($this->allowCaching)
314 314
             $this->cache['first'] = $entity;
315 315
 
316 316
         return $entity;
@@ -324,16 +324,16 @@  discard block
 block discarded – undo
324 324
      */
325 325
     public function last($filter = [], $columns = ['*'])
326 326
     {
327
-        if($this->allowCaching)
327
+        if ($this->allowCaching)
328 328
         {
329 329
             if (isset($this->cache['last']))
330 330
                 return $this->cache['last'];
331 331
         }
332 332
 
333 333
         $entity = $this->model->with($this->with)->select($columns)->where($filter)
334
-            ->orderBy('id','desc')->first();
334
+            ->orderBy('id', 'desc')->first();
335 335
 
336
-        if($this->allowCaching)
336
+        if ($this->allowCaching)
337 337
             $this->cache['last'] = $entity;
338 338
 
339 339
         return $entity;
Please login to merge, or discard this patch.
Braces   +24 added lines, -16 removed lines patch added patch discarded remove patch
@@ -258,14 +258,16 @@  discard block
 block discarded – undo
258 258
     {
259 259
         if($this->allowCaching)
260 260
         {
261
-            if (isset($this->cache[$entityId]))
262
-                return $this->cache[$entityId];
261
+            if (isset($this->cache[$entityId])) {
262
+                            return $this->cache[$entityId];
263
+            }
263 264
         }
264 265
 
265 266
         $entity = $this->model->with($this->with)->find($entityId, $columns);
266 267
 
267
-        if($this->allowCaching)
268
-            $this->cache[$entityId] = $entity;
268
+        if($this->allowCaching) {
269
+                    $this->cache[$entityId] = $entity;
270
+        }
269 271
 
270 272
         return $entity;
271 273
     }
@@ -282,14 +284,16 @@  discard block
 block discarded – undo
282 284
     {
283 285
         if($this->allowCaching)
284 286
         {
285
-            if (isset($this->cache[$entityId]))
286
-                return $this->cache[$entityId];
287
+            if (isset($this->cache[$entityId])) {
288
+                            return $this->cache[$entityId];
289
+            }
287 290
         }
288 291
 
289 292
         $entity = $this->model->with($this->with)->findOrFail($entityId, $columns);
290 293
 
291
-        if($this->allowCaching)
292
-            $this->cache[$entityId] = $entity;
294
+        if($this->allowCaching) {
295
+                    $this->cache[$entityId] = $entity;
296
+        }
293 297
 
294 298
         return $entity;
295 299
     }
@@ -304,14 +308,16 @@  discard block
 block discarded – undo
304 308
     {
305 309
         if($this->allowCaching)
306 310
         {
307
-            if (isset($this->cache['first']))
308
-                return $this->cache['first'];
311
+            if (isset($this->cache['first'])) {
312
+                            return $this->cache['first'];
313
+            }
309 314
         }
310 315
 
311 316
         $entity = $this->model->with($this->with)->select($columns)->where($filter)->first();
312 317
 
313
-        if($this->allowCaching)
314
-            $this->cache['first'] = $entity;
318
+        if($this->allowCaching) {
319
+                    $this->cache['first'] = $entity;
320
+        }
315 321
 
316 322
         return $entity;
317 323
     }
@@ -326,15 +332,17 @@  discard block
 block discarded – undo
326 332
     {
327 333
         if($this->allowCaching)
328 334
         {
329
-            if (isset($this->cache['last']))
330
-                return $this->cache['last'];
335
+            if (isset($this->cache['last'])) {
336
+                            return $this->cache['last'];
337
+            }
331 338
         }
332 339
 
333 340
         $entity = $this->model->with($this->with)->select($columns)->where($filter)
334 341
             ->orderBy('id','desc')->first();
335 342
 
336
-        if($this->allowCaching)
337
-            $this->cache['last'] = $entity;
343
+        if($this->allowCaching) {
344
+                    $this->cache['last'] = $entity;
345
+        }
338 346
 
339 347
         return $entity;
340 348
     }
Please login to merge, or discard this patch.