@@ -432,8 +432,7 @@ discard block |
||
| 432 | 432 | $model = $this->model->lockForUpdate()->find($value); |
| 433 | 433 | $model ? $model->update($data) : 0; |
| 434 | 434 | $saveLog ? \Logging::saveLog('update', class_basename($this->model), $this->getModel(), $value, $model) : false; |
| 435 | - } |
|
| 436 | - else |
|
| 435 | + } else |
|
| 437 | 436 | { |
| 438 | 437 | call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($data, $saveLog){ |
| 439 | 438 | $model->update($data); |
@@ -464,8 +463,7 @@ discard block |
||
| 464 | 463 | $model->delete(); |
| 465 | 464 | $saveLog ? \Logging::saveLog('delete', class_basename($this->model), $this->getModel(), $value, $model) : false; |
| 466 | 465 | }); |
| 467 | - } |
|
| 468 | - else |
|
| 466 | + } else |
|
| 469 | 467 | { |
| 470 | 468 | \DB::transaction(function () use ($value, $attribute, &$result, $saveLog) { |
| 471 | 469 | call_user_func_array("{$this->getModel()}::where", array($attribute, '=', $value))->lockForUpdate()->get()->each(function ($model) use ($saveLog){ |
@@ -582,14 +580,12 @@ discard block |
||
| 582 | 580 | $conditions = $this->constructConditions($value, $model); |
| 583 | 581 | $conditionString .= str_replace('{op}', 'and', $conditions['conditionString']) . ' {op} '; |
| 584 | 582 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 585 | - } |
|
| 586 | - else if ($key == 'or') |
|
| 583 | + } else if ($key == 'or') |
|
| 587 | 584 | { |
| 588 | 585 | $conditions = $this->constructConditions($value, $model); |
| 589 | 586 | $conditionString .= str_replace('{op}', 'or', $conditions['conditionString']) . ' {op} '; |
| 590 | 587 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 591 | - } |
|
| 592 | - else |
|
| 588 | + } else |
|
| 593 | 589 | { |
| 594 | 590 | if (is_array($value)) |
| 595 | 591 | { |
@@ -598,13 +594,11 @@ discard block |
||
| 598 | 594 | { |
| 599 | 595 | $value1 = $value['val1']; |
| 600 | 596 | $value2 = $value['val2']; |
| 601 | - } |
|
| 602 | - else |
|
| 597 | + } else |
|
| 603 | 598 | { |
| 604 | 599 | $value = array_key_exists('val', $value) ? $value['val'] : ''; |
| 605 | 600 | } |
| 606 | - } |
|
| 607 | - else |
|
| 601 | + } else |
|
| 608 | 602 | { |
| 609 | 603 | $operator = '='; |
| 610 | 604 | } |
@@ -616,29 +610,24 @@ discard block |
||
| 616 | 610 | |
| 617 | 611 | $conditionString .= $key . ' <= ? {op} '; |
| 618 | 612 | $conditionValues[] = $value2; |
| 619 | - } |
|
| 620 | - elseif (strtolower($operator) == 'in') |
|
| 613 | + } elseif (strtolower($operator) == 'in') |
|
| 621 | 614 | { |
| 622 | 615 | $conditionValues = array_merge($conditionValues, $value); |
| 623 | 616 | $inBindingsString = rtrim(str_repeat('?,', count($value)), ','); |
| 624 | 617 | $conditionString .= $key . ' in (' . rtrim($inBindingsString, ',') . ') {op} '; |
| 625 | - } |
|
| 626 | - elseif (strtolower($operator) == 'null') |
|
| 618 | + } elseif (strtolower($operator) == 'null') |
|
| 627 | 619 | { |
| 628 | 620 | $conditionString .= $key . ' is null {op} '; |
| 629 | - } |
|
| 630 | - elseif (strtolower($operator) == 'not null') |
|
| 621 | + } elseif (strtolower($operator) == 'not null') |
|
| 631 | 622 | { |
| 632 | 623 | $conditionString .= $key . ' is not null {op} '; |
| 633 | - } |
|
| 634 | - elseif (strtolower($operator) == 'has') |
|
| 624 | + } elseif (strtolower($operator) == 'has') |
|
| 635 | 625 | { |
| 636 | 626 | $sql = $model->withTrashed()->has($key)->toSql(); |
| 637 | 627 | $conditions = $this->constructConditions($value, $model->$key()->getRelated()); |
| 638 | 628 | $conditionString .= rtrim(substr($sql, strpos($sql, 'exists')), ')') . ' and ' . $conditions['conditionString'] . ') {op} '; |
| 639 | 629 | $conditionValues = array_merge($conditionValues, $conditions['conditionValues']); |
| 640 | - } |
|
| 641 | - else |
|
| 630 | + } else |
|
| 642 | 631 | { |
| 643 | 632 | $conditionString .= $key . ' ' . $operator . ' ? {op} '; |
| 644 | 633 | $conditionValues[] = $value; |