@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * |
33 | 33 | * @param array $relations |
34 | 34 | * @param string $sortBy |
35 | - * @param boolean $desc |
|
35 | + * @param integer $desc |
|
36 | 36 | * @param array $columns |
37 | 37 | * @return collection |
38 | 38 | */ |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | * @param integer $perPage |
51 | 51 | * @param array $relations |
52 | 52 | * @param string $sortBy |
53 | - * @param boolean $desc |
|
53 | + * @param integer $desc |
|
54 | 54 | * @param array $columns |
55 | 55 | * @return collection |
56 | 56 | */ |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | * @param integer $perPage |
140 | 140 | * @param array $relations |
141 | 141 | * @param string $sortBy |
142 | - * @param boolean $desc |
|
142 | + * @param integer $desc |
|
143 | 143 | * @param array $columns |
144 | 144 | * @return collection |
145 | 145 | */ |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | * @param integer $perPage |
158 | 158 | * @param array $relations |
159 | 159 | * @param string $sortBy |
160 | - * @param boolean $desc |
|
160 | + * @param integer $desc |
|
161 | 161 | * @param array $columns |
162 | 162 | * @return collection |
163 | 163 | */ |
@@ -418,7 +418,7 @@ discard block |
||
418 | 418 | * Update record in the storage based on the given |
419 | 419 | * condition. |
420 | 420 | * |
421 | - * @param var $value condition value |
|
421 | + * @param boolean $value condition value |
|
422 | 422 | * @param array $data |
423 | 423 | * @param string $attribute condition column name |
424 | 424 | * @return void |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | * id. |
480 | 480 | * |
481 | 481 | * @param integer $id |
482 | - * @param array $relations |
|
482 | + * @param string[] $relations |
|
483 | 483 | * @param array $columns |
484 | 484 | * @return object |
485 | 485 | */ |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | * @param array $conditions array of conditions |
496 | 496 | * @param array $relations |
497 | 497 | * @param string $sortBy |
498 | - * @param boolean $desc |
|
498 | + * @param integer $desc |
|
499 | 499 | * @param array $columns |
500 | 500 | * @return collection |
501 | 501 | */ |
@@ -527,7 +527,7 @@ discard block |
||
527 | 527 | * @param array $conditions array of conditions |
528 | 528 | * @param integer $perPage |
529 | 529 | * @param string $sortBy |
530 | - * @param boolean $desc |
|
530 | + * @param integer $desc |
|
531 | 531 | * @param array $columns |
532 | 532 | * @return collection |
533 | 533 | */ |
@@ -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'] . ')'; |
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; |