@@ 611-619 (lines=9) @@ | ||
608 | * |
|
609 | * @return \Illuminate\Database\Eloquent\Builder|static |
|
610 | */ |
|
611 | public function scopeWhereTranslation(Builder $query, $key, $value, $locale = null) |
|
612 | { |
|
613 | return $query->whereHas('translations', function (Builder $query) use ($key, $value, $locale) { |
|
614 | $query->where($this->getTranslationsTable().'.'.$key, $value); |
|
615 | if ($locale) { |
|
616 | $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), $locale); |
|
617 | } |
|
618 | }); |
|
619 | } |
|
620 | ||
621 | /** |
|
622 | * This scope filters results by checking the translation fields. |
|
@@ 631-639 (lines=9) @@ | ||
628 | * |
|
629 | * @return \Illuminate\Database\Eloquent\Builder|static |
|
630 | */ |
|
631 | public function scopeOrWhereTranslation(Builder $query, $key, $value, $locale = null) |
|
632 | { |
|
633 | return $query->orWhereHas('translations', function (Builder $query) use ($key, $value, $locale) { |
|
634 | $query->where($this->getTranslationsTable().'.'.$key, $value); |
|
635 | if ($locale) { |
|
636 | $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), $locale); |
|
637 | } |
|
638 | }); |
|
639 | } |
|
640 | ||
641 | /** |
|
642 | * This scope filters results by checking the translation fields. |
|
@@ 651-659 (lines=9) @@ | ||
648 | * |
|
649 | * @return \Illuminate\Database\Eloquent\Builder|static |
|
650 | */ |
|
651 | public function scopeWhereTranslationLike(Builder $query, $key, $value, $locale = null) |
|
652 | { |
|
653 | return $query->whereHas('translations', function (Builder $query) use ($key, $value, $locale) { |
|
654 | $query->where($this->getTranslationsTable().'.'.$key, 'LIKE', $value); |
|
655 | if ($locale) { |
|
656 | $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), 'LIKE', $locale); |
|
657 | } |
|
658 | }); |
|
659 | } |
|
660 | ||
661 | /** |
|
662 | * This scope filters results by checking the translation fields. |
|
@@ 671-679 (lines=9) @@ | ||
668 | * |
|
669 | * @return \Illuminate\Database\Eloquent\Builder|static |
|
670 | */ |
|
671 | public function scopeOrWhereTranslationLike(Builder $query, $key, $value, $locale = null) |
|
672 | { |
|
673 | return $query->orWhereHas('translations', function (Builder $query) use ($key, $value, $locale) { |
|
674 | $query->where($this->getTranslationsTable().'.'.$key, 'LIKE', $value); |
|
675 | if ($locale) { |
|
676 | $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), 'LIKE', $locale); |
|
677 | } |
|
678 | }); |
|
679 | } |
|
680 | ||
681 | /** |
|
682 | * This scope sorts results by the given translation field. |