|
@@ 617-625 (lines=9) @@
|
| 614 |
|
* |
| 615 |
|
* @return \Illuminate\Database\Eloquent\Builder|static |
| 616 |
|
*/ |
| 617 |
|
public function scopeWhereTranslation(Builder $query, $key, $value, $locale = null) |
| 618 |
|
{ |
| 619 |
|
return $query->whereHas('translations', function (Builder $query) use ($key, $value, $locale) { |
| 620 |
|
$query->where($this->getTranslationsTable().'.'.$key, $value); |
| 621 |
|
if ($locale) { |
| 622 |
|
$query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), $locale); |
| 623 |
|
} |
| 624 |
|
}); |
| 625 |
|
} |
| 626 |
|
|
| 627 |
|
/** |
| 628 |
|
* This scope filters results by checking the translation fields. |
|
@@ 637-645 (lines=9) @@
|
| 634 |
|
* |
| 635 |
|
* @return \Illuminate\Database\Eloquent\Builder|static |
| 636 |
|
*/ |
| 637 |
|
public function scopeOrWhereTranslation(Builder $query, $key, $value, $locale = null) |
| 638 |
|
{ |
| 639 |
|
return $query->orWhereHas('translations', function (Builder $query) use ($key, $value, $locale) { |
| 640 |
|
$query->where($this->getTranslationsTable().'.'.$key, $value); |
| 641 |
|
if ($locale) { |
| 642 |
|
$query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), $locale); |
| 643 |
|
} |
| 644 |
|
}); |
| 645 |
|
} |
| 646 |
|
|
| 647 |
|
/** |
| 648 |
|
* This scope filters results by checking the translation fields. |
|
@@ 657-665 (lines=9) @@
|
| 654 |
|
* |
| 655 |
|
* @return \Illuminate\Database\Eloquent\Builder|static |
| 656 |
|
*/ |
| 657 |
|
public function scopeWhereTranslationLike(Builder $query, $key, $value, $locale = null) |
| 658 |
|
{ |
| 659 |
|
return $query->whereHas('translations', function (Builder $query) use ($key, $value, $locale) { |
| 660 |
|
$query->where($this->getTranslationsTable().'.'.$key, 'LIKE', $value); |
| 661 |
|
if ($locale) { |
| 662 |
|
$query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), 'LIKE', $locale); |
| 663 |
|
} |
| 664 |
|
}); |
| 665 |
|
} |
| 666 |
|
|
| 667 |
|
/** |
| 668 |
|
* This scope filters results by checking the translation fields. |
|
@@ 677-685 (lines=9) @@
|
| 674 |
|
* |
| 675 |
|
* @return \Illuminate\Database\Eloquent\Builder|static |
| 676 |
|
*/ |
| 677 |
|
public function scopeOrWhereTranslationLike(Builder $query, $key, $value, $locale = null) |
| 678 |
|
{ |
| 679 |
|
return $query->orWhereHas('translations', function (Builder $query) use ($key, $value, $locale) { |
| 680 |
|
$query->where($this->getTranslationsTable().'.'.$key, 'LIKE', $value); |
| 681 |
|
if ($locale) { |
| 682 |
|
$query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), 'LIKE', $locale); |
| 683 |
|
} |
| 684 |
|
}); |
| 685 |
|
} |
| 686 |
|
|
| 687 |
|
/** |
| 688 |
|
* This scope sorts results by the given translation field. |