Completed
Push — master ( c1b837...1e8b34 )
by Sherif
07:31
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){
@@ -581,14 +579,12 @@  discard block
 block discarded – undo
581 579
                 $conditions       = $this->constructConditions($value, $model);
582 580
                 $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']) . ' {op} ';
583 581
                 $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
584
-            }
585
-            else if ($key == 'or')
582
+            } else if ($key == 'or')
586 583
             {
587 584
                 $conditions       = $this->constructConditions($value, $model);
588 585
                 $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']) . ' {op} ';
589 586
                 $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
590
-            }
591
-            else
587
+            } else
592 588
             {
593 589
                 if (is_array($value)) 
594 590
                 {
@@ -597,13 +593,11 @@  discard block
 block discarded – undo
597 593
                     {
598 594
                         $value1 = $value['val1'];
599 595
                         $value2 = $value['val2'];
600
-                    }
601
-                    else
596
+                    } else
602 597
                     {
603 598
                         $value = array_key_exists('val', $value) ? $value['val'] : '';
604 599
                     }
605
-                }
606
-                else
600
+                } else
607 601
                 {
608 602
                     $operator = '=';
609 603
                 }
@@ -615,29 +609,24 @@  discard block
 block discarded – undo
615 609
 
616 610
                     $conditionString  .= $key . ' <= ? {op} ';
617 611
                     $conditionValues[] = $value2;
618
-                }
619
-                elseif (strtolower($operator) == 'in') 
612
+                } elseif (strtolower($operator) == 'in') 
620 613
                 {
621 614
                     $conditionValues  = array_merge($conditionValues, $value);
622 615
                     $inBindingsString = rtrim(str_repeat('?,', count($value)), ',');
623 616
                     $conditionString .= $key . ' in (' . rtrim($inBindingsString, ',') . ') {op} ';
624
-                }
625
-                elseif (strtolower($operator) == 'null') 
617
+                } elseif (strtolower($operator) == 'null') 
626 618
                 {
627 619
                     $conditionString .= $key . ' is null {op} ';
628
-                }
629
-                elseif (strtolower($operator) == 'not null') 
620
+                } elseif (strtolower($operator) == 'not null') 
630 621
                 {
631 622
                     $conditionString .= $key . ' is not null {op} ';
632
-                }
633
-                elseif (strtolower($operator) == 'has') 
623
+                } elseif (strtolower($operator) == 'has') 
634 624
                 {
635 625
                     $sql              = $model->withTrashed()->has($key)->toSql();
636 626
                     $conditions       = $this->constructConditions($value, $model->first()->$key);
637 627
                     $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')') . ' and ' . $conditions['conditionString'] . ')';
638 628
                     $conditionValues  = array_merge($conditionValues, $conditions['conditionValues']);
639
-                }
640
-                else
629
+                } else
641 630
                 {
642 631
                     $conditionString  .= $key . ' ' . $operator . ' ? {op} ';
643 632
                     $conditionValues[] = $value;
Please login to merge, or discard this patch.