Code Duplication    Length = 9-9 lines in 4 locations

src/Translatable/Translatable.php 4 locations

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