Code Duplication    Length = 9-9 lines in 4 locations

src/Translatable/Translatable.php 4 locations

@@ 632-640 (lines=9) @@
629
     *
630
     * @return \Illuminate\Database\Eloquent\Builder|static
631
     */
632
    public function scopeWhereTranslation(Builder $query, $key, $value, $locale = null)
633
    {
634
        return $query->whereHas('translations', function (Builder $query) use ($key, $value, $locale) {
635
            $query->where($this->getTranslationsTable().'.'.$key, $value);
636
            if ($locale) {
637
                $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), $locale);
638
            }
639
        });
640
    }
641
642
    /**
643
     * This scope filters results by checking the translation fields.
@@ 652-660 (lines=9) @@
649
     *
650
     * @return \Illuminate\Database\Eloquent\Builder|static
651
     */
652
    public function scopeOrWhereTranslation(Builder $query, $key, $value, $locale = null)
653
    {
654
        return $query->orWhereHas('translations', function (Builder $query) use ($key, $value, $locale) {
655
            $query->where($this->getTranslationsTable().'.'.$key, $value);
656
            if ($locale) {
657
                $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), $locale);
658
            }
659
        });
660
    }
661
662
    /**
663
     * This scope filters results by checking the translation fields.
@@ 672-680 (lines=9) @@
669
     *
670
     * @return \Illuminate\Database\Eloquent\Builder|static
671
     */
672
    public function scopeWhereTranslationLike(Builder $query, $key, $value, $locale = null)
673
    {
674
        return $query->whereHas('translations', function (Builder $query) use ($key, $value, $locale) {
675
            $query->where($this->getTranslationsTable().'.'.$key, 'LIKE', $value);
676
            if ($locale) {
677
                $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), 'LIKE', $locale);
678
            }
679
        });
680
    }
681
682
    /**
683
     * This scope filters results by checking the translation fields.
@@ 692-700 (lines=9) @@
689
     *
690
     * @return \Illuminate\Database\Eloquent\Builder|static
691
     */
692
    public function scopeOrWhereTranslationLike(Builder $query, $key, $value, $locale = null)
693
    {
694
        return $query->orWhereHas('translations', function (Builder $query) use ($key, $value, $locale) {
695
            $query->where($this->getTranslationsTable().'.'.$key, 'LIKE', $value);
696
            if ($locale) {
697
                $query->where($this->getTranslationsTable().'.'.$this->getLocaleKey(), 'LIKE', $locale);
698
            }
699
        });
700
    }
701
702
    /**
703
     * This scope sorts results by the given translation field.