@@ 635-643 (lines=9) @@ | ||
632 | * |
|
633 | * @return \Illuminate\Database\Eloquent\Builder|static |
|
634 | */ |
|
635 | public function scopeWhereTranslation(Builder $query, $key, $value, $locale = null) |
|
636 | { |
|
637 | return $query->whereHas('translations', function (Builder $query) use ($key, $value, $locale) { |
|
638 | $query->where($this->getTranslationsTable().'.'.$key, $value); |
|
639 | if ($locale) { |
|
640 | $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), $locale); |
|
641 | } |
|
642 | }); |
|
643 | } |
|
644 | ||
645 | /** |
|
646 | * This scope filters results by checking the translation fields. |
|
@@ 655-663 (lines=9) @@ | ||
652 | * |
|
653 | * @return \Illuminate\Database\Eloquent\Builder|static |
|
654 | */ |
|
655 | public function scopeOrWhereTranslation(Builder $query, $key, $value, $locale = null) |
|
656 | { |
|
657 | return $query->orWhereHas('translations', function (Builder $query) use ($key, $value, $locale) { |
|
658 | $query->where($this->getTranslationsTable().'.'.$key, $value); |
|
659 | if ($locale) { |
|
660 | $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), $locale); |
|
661 | } |
|
662 | }); |
|
663 | } |
|
664 | ||
665 | /** |
|
666 | * This scope filters results by checking the translation fields. |
|
@@ 675-683 (lines=9) @@ | ||
672 | * |
|
673 | * @return \Illuminate\Database\Eloquent\Builder|static |
|
674 | */ |
|
675 | public function scopeWhereTranslationLike(Builder $query, $key, $value, $locale = null) |
|
676 | { |
|
677 | return $query->whereHas('translations', function (Builder $query) use ($key, $value, $locale) { |
|
678 | $query->where($this->getTranslationsTable().'.'.$key, 'LIKE', $value); |
|
679 | if ($locale) { |
|
680 | $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), 'LIKE', $locale); |
|
681 | } |
|
682 | }); |
|
683 | } |
|
684 | ||
685 | /** |
|
686 | * This scope filters results by checking the translation fields. |
|
@@ 695-703 (lines=9) @@ | ||
692 | * |
|
693 | * @return \Illuminate\Database\Eloquent\Builder|static |
|
694 | */ |
|
695 | public function scopeOrWhereTranslationLike(Builder $query, $key, $value, $locale = null) |
|
696 | { |
|
697 | return $query->orWhereHas('translations', function (Builder $query) use ($key, $value, $locale) { |
|
698 | $query->where($this->getTranslationsTable().'.'.$key, 'LIKE', $value); |
|
699 | if ($locale) { |
|
700 | $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), 'LIKE', $locale); |
|
701 | } |
|
702 | }); |
|
703 | } |
|
704 | ||
705 | /** |
|
706 | * This scope sorts results by the given translation field. |