Code Duplication    Length = 10-12 lines in 2 locations

app/Models/Traits/HasTags.php 2 locations

@@ 83-94 (lines=12) @@
80
     *
81
     * @return \Illuminate\Database\Eloquent\Builder
82
     */
83
    public function scopeWithAllTags(Builder $query, $tags)
84
    {
85
        $tags = static::convertToTags($tags);
86
87
        $tags->each(function ($tag) use ($query) {
88
            $query->whereHas('tags', function (Builder $query) use ($tag) {
89
                return $query->where('tags.id', $tag ? $tag->id : 0);
90
            });
91
        });
92
93
        return $query;
94
    }
95
96
    /**
97
     * @param \Illuminate\Database\Eloquent\Builder $query
@@ 102-111 (lines=10) @@
99
     *
100
     * @return \Illuminate\Database\Eloquent\Builder
101
     */
102
    public function scopeWithAnyTags(Builder $query, $tags)
103
    {
104
        $tags = static::convertToTags($tags);
105
106
        return $query->whereHas('tags', function (Builder $query) use ($tags) {
107
            $tagIds = collect($tags)->pluck('id');
108
109
            $query->whereIn('tags.id', $tagIds);
110
        });
111
    }
112
113
    /**
114
     * @param array|\ArrayAccess|\CachetHQ\Cachet\Models\Tag $tags