@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * |
| 41 | 41 | * @param array $relations |
| 42 | 42 | * @param string $sortBy |
| 43 | - * @param boolean $desc |
|
| 43 | + * @param integer $desc |
|
| 44 | 44 | * @param array $columns |
| 45 | 45 | * @return collection |
| 46 | 46 | */ |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @param integer $perPage |
| 61 | 61 | * @param array $relations |
| 62 | 62 | * @param string $sortBy |
| 63 | - * @param boolean $desc |
|
| 63 | + * @param integer $desc |
|
| 64 | 64 | * @param array $columns |
| 65 | 65 | * @return collection |
| 66 | 66 | */ |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | * @param integer $perPage |
| 80 | 80 | * @param array $relations |
| 81 | 81 | * @param string $sortBy |
| 82 | - * @param boolean $desc |
|
| 82 | + * @param integer $desc |
|
| 83 | 83 | * @param array $columns |
| 84 | 84 | * @return collection |
| 85 | 85 | */ |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | * @param integer $perPage |
| 101 | 101 | * @param array $relations |
| 102 | 102 | * @param string $sortBy |
| 103 | - * @param boolean $desc |
|
| 103 | + * @param integer $desc |
|
| 104 | 104 | * @param array $columns |
| 105 | 105 | * @return collection |
| 106 | 106 | */ |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | * @param array $conditions array of conditions |
| 180 | 180 | * @param array $relations |
| 181 | 181 | * @param string $sortBy |
| 182 | - * @param boolean $desc |
|
| 182 | + * @param integer $desc |
|
| 183 | 183 | * @param array $columns |
| 184 | 184 | * @return collection |
| 185 | 185 | */ |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | * @param array $conditions array of conditions |
| 215 | 215 | * @param integer $perPage |
| 216 | 216 | * @param string $sortBy |
| 217 | - * @param boolean $desc |
|
| 217 | + * @param integer $desc |
|
| 218 | 218 | * @param array $columns |
| 219 | 219 | * @return collection |
| 220 | 220 | */ |
@@ -430,8 +430,7 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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'] . ') {op} '; |
| 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; |