Code Duplication    Length = 9-9 lines in 4 locations

src/Translatable/Translatable.php 4 locations

@@ 641-649 (lines=9) @@
638
     *
639
     * @return \Illuminate\Database\Eloquent\Builder|static
640
     */
641
    public function scopeWhereTranslation(Builder $query, $key, $value, $locale = null)
642
    {
643
        return $query->whereHas('translations', function (Builder $query) use ($key, $value, $locale) {
644
            $query->where($this->getTranslationsTable().'.'.$key, $value);
645
            if ($locale) {
646
                $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), $locale);
647
            }
648
        });
649
    }
650
651
    /**
652
     * This scope filters results by checking the translation fields.
@@ 661-669 (lines=9) @@
658
     *
659
     * @return \Illuminate\Database\Eloquent\Builder|static
660
     */
661
    public function scopeOrWhereTranslation(Builder $query, $key, $value, $locale = null)
662
    {
663
        return $query->orWhereHas('translations', function (Builder $query) use ($key, $value, $locale) {
664
            $query->where($this->getTranslationsTable().'.'.$key, $value);
665
            if ($locale) {
666
                $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), $locale);
667
            }
668
        });
669
    }
670
671
    /**
672
     * This scope filters results by checking the translation fields.
@@ 681-689 (lines=9) @@
678
     *
679
     * @return \Illuminate\Database\Eloquent\Builder|static
680
     */
681
    public function scopeWhereTranslationLike(Builder $query, $key, $value, $locale = null)
682
    {
683
        return $query->whereHas('translations', function (Builder $query) use ($key, $value, $locale) {
684
            $query->where($this->getTranslationsTable().'.'.$key, 'LIKE', $value);
685
            if ($locale) {
686
                $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), 'LIKE', $locale);
687
            }
688
        });
689
    }
690
691
    /**
692
     * This scope filters results by checking the translation fields.
@@ 701-709 (lines=9) @@
698
     *
699
     * @return \Illuminate\Database\Eloquent\Builder|static
700
     */
701
    public function scopeOrWhereTranslationLike(Builder $query, $key, $value, $locale = null)
702
    {
703
        return $query->orWhereHas('translations', function (Builder $query) use ($key, $value, $locale) {
704
            $query->where($this->getTranslationsTable().'.'.$key, 'LIKE', $value);
705
            if ($locale) {
706
                $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), 'LIKE', $locale);
707
            }
708
        });
709
    }
710
711
    /**
712
     * This scope sorts results by the given translation field.