Фильтр из Taggable laravel

$searchdata = ['A','B']; //keep it as an array
if(count($searchdata) > 1) {
    $data = User::with('tags')
                      ->orWhereHas('tags', function($q) use ($searchdata){
                            $q->whereIn('name', $searchdata);
                      })->get();

} else {
    $data = User::with('tags')
                      ->orWhereHas('tags', function($q) use ($searchdata){
                            $q->where('name', 'LIKE', '%' . $searchdata[0] . '%');
                       })->get();

}
Innocent Ibex