Code Duplication    Length = 9-9 lines in 4 locations

src/Translatable/Translatable.php 4 locations

@@ 646-654 (lines=9) @@
643
     *
644
     * @return \Illuminate\Database\Eloquent\Builder|static
645
     */
646
    public function scopeWhereTranslation(Builder $query, $key, $value, $locale = null)
647
    {
648
        return $query->whereHas('translations', function (Builder $query) use ($key, $value, $locale) {
649
            $query->where($this->getTranslationsTable().'.'.$key, $value);
650
            if ($locale) {
651
                $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), $locale);
652
            }
653
        });
654
    }
655
656
    /**
657
     * This scope filters results by checking the translation fields.
@@ 666-674 (lines=9) @@
663
     *
664
     * @return \Illuminate\Database\Eloquent\Builder|static
665
     */
666
    public function scopeOrWhereTranslation(Builder $query, $key, $value, $locale = null)
667
    {
668
        return $query->orWhereHas('translations', function (Builder $query) use ($key, $value, $locale) {
669
            $query->where($this->getTranslationsTable().'.'.$key, $value);
670
            if ($locale) {
671
                $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), $locale);
672
            }
673
        });
674
    }
675
676
    /**
677
     * This scope filters results by checking the translation fields.
@@ 686-694 (lines=9) @@
683
     *
684
     * @return \Illuminate\Database\Eloquent\Builder|static
685
     */
686
    public function scopeWhereTranslationLike(Builder $query, $key, $value, $locale = null)
687
    {
688
        return $query->whereHas('translations', function (Builder $query) use ($key, $value, $locale) {
689
            $query->where($this->getTranslationsTable().'.'.$key, 'LIKE', $value);
690
            if ($locale) {
691
                $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), 'LIKE', $locale);
692
            }
693
        });
694
    }
695
696
    /**
697
     * This scope filters results by checking the translation fields.
@@ 706-714 (lines=9) @@
703
     *
704
     * @return \Illuminate\Database\Eloquent\Builder|static
705
     */
706
    public function scopeOrWhereTranslationLike(Builder $query, $key, $value, $locale = null)
707
    {
708
        return $query->orWhereHas('translations', function (Builder $query) use ($key, $value, $locale) {
709
            $query->where($this->getTranslationsTable().'.'.$key, 'LIKE', $value);
710
            if ($locale) {
711
                $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), 'LIKE', $locale);
712
            }
713
        });
714
    }
715
716
    /**
717
     * This scope sorts results by the given translation field.