Code Duplication    Length = 9-9 lines in 4 locations

src/Translatable/Translatable.php 4 locations

@@ 637-645 (lines=9) @@
634
     *
635
     * @return \Illuminate\Database\Eloquent\Builder|static
636
     */
637
    public function scopeWhereTranslation(Builder $query, $key, $value, $locale = null)
638
    {
639
        return $query->whereHas('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 scopeOrWhereTranslation(Builder $query, $key, $value, $locale = null)
658
    {
659
        return $query->orWhereHas('translations', function (Builder $query) use ($key, $value, $locale) {
660
            $query->where($this->getTranslationsTable().'.'.$key, $value);
661
            if ($locale) {
662
                $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), $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 scopeWhereTranslationLike(Builder $query, $key, $value, $locale = null)
678
    {
679
        return $query->whereHas('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 filters results by checking the translation fields.
@@ 697-705 (lines=9) @@
694
     *
695
     * @return \Illuminate\Database\Eloquent\Builder|static
696
     */
697
    public function scopeOrWhereTranslationLike(Builder $query, $key, $value, $locale = null)
698
    {
699
        return $query->orWhereHas('translations', function (Builder $query) use ($key, $value, $locale) {
700
            $query->where($this->getTranslationsTable().'.'.$key, 'LIKE', $value);
701
            if ($locale) {
702
                $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), 'LIKE', $locale);
703
            }
704
        });
705
    }
706
707
    /**
708
     * This scope sorts results by the given translation field.