Completed
Push — master ( 1e8b34...bf4aa0 )
by Sherif
02:38
created
src/Modules/V1/Core/AbstractRepositories/AbstractRepository.php 1 patch
Braces   +11 added lines, -22 removed lines patch added patch discarded remove patch
@@ -430,8 +430,7 @@  discard block
 block discarded – undo
430 430
             $model = $this->model->lockForUpdate()->find($value);
431 431
             $model ? $model->update($data) : 0;
432 432
             $saveLog ? \Logging::saveLog('update', class_basename($this->model), $this->getModel(), $value, $model) : false;
433
-        }
434
-        else
433
+        } else
435 434
         {
436 435
             call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($data, $saveLog){
437 436
                 $model->update($data);
@@ -462,8 +461,7 @@  discard block
 block discarded – undo
462 461
                 $model->delete();
463 462
                 $saveLog ? \Logging::saveLog('delete', class_basename($this->model), $this->getModel(), $value, $model) : false;
464 463
             });
465
-        }
466
-        else
464
+        } else
467 465
         {
468 466
             \DB::transaction(function () use ($value, $attribute, &$result, $saveLog) {
469 467
                 call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($saveLog){
@@ -580,14 +578,12 @@  discard block
 block discarded – undo
580 578
                 $conditions       = $this->constructConditions($value, $model);
581 579
                 $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']) . ' {op} ';
582 580
                 $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
583
-            }
584
-            else if ($key == 'or')
581
+            } else if ($key == 'or')
585 582
             {
586 583
                 $conditions       = $this->constructConditions($value, $model);
587 584
                 $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']) . ' {op} ';
588 585
                 $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
589
-            }
590
-            else
586
+            } else
591 587
             {
592 588
                 if (is_array($value)) 
593 589
                 {
@@ -596,13 +592,11 @@  discard block
 block discarded – undo
596 592
                     {
597 593
                         $value1 = $value['val1'];
598 594
                         $value2 = $value['val2'];
599
-                    }
600
-                    else
595
+                    } else
601 596
                     {
602 597
                         $value = array_key_exists('val', $value) ? $value['val'] : '';
603 598
                     }
604
-                }
605
-                else
599
+                } else
606 600
                 {
607 601
                     $operator = '=';
608 602
                 }
@@ -614,29 +608,24 @@  discard block
 block discarded – undo
614 608
 
615 609
                     $conditionString  .= $key . ' <= ? {op} ';
616 610
                     $conditionValues[] = $value2;
617
-                }
618
-                elseif (strtolower($operator) == 'in') 
611
+                } elseif (strtolower($operator) == 'in') 
619 612
                 {
620 613
                     $conditionValues  = array_merge($conditionValues, $value);
621 614
                     $inBindingsString = rtrim(str_repeat('?,', count($value)), ',');
622 615
                     $conditionString .= $key . ' in (' . rtrim($inBindingsString, ',') . ') {op} ';
623
-                }
624
-                elseif (strtolower($operator) == 'null') 
616
+                } elseif (strtolower($operator) == 'null') 
625 617
                 {
626 618
                     $conditionString .= $key . ' is null {op} ';
627
-                }
628
-                elseif (strtolower($operator) == 'not null') 
619
+                } elseif (strtolower($operator) == 'not null') 
629 620
                 {
630 621
                     $conditionString .= $key . ' is not null {op} ';
631
-                }
632
-                elseif (strtolower($operator) == 'has') 
622
+                } elseif (strtolower($operator) == 'has') 
633 623
                 {
634 624
                     $sql              = $model->withTrashed()->has($key)->toSql();
635 625
                     $conditions       = $this->constructConditions($value, $model->first()->$key);
636 626
                     $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')') . ' and ' . $conditions['conditionString'] . ')';
637 627
                     $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
638
-                }
639
-                else
628
+                } else
640 629
                 {
641 630
                     $conditionString  .= $key . ' ' . $operator . ' ? {op} ';
642 631
                     $conditionValues[] = $value;
Please login to merge, or discard this patch.