Are you not using relations? This would be a lot easier with them. Also, your naming conventions are a little weird, as you're using singular name for a collection and a plural name for a single instance.
public function filterCategory() {
$categories = Category::with('brands')->select('id')->get();
return view('category', compact('categories'));
}
@foreach ($categories as $category)
@foreach ($category->brands as $brand)
Brand: {{ $brand->name }}
@endforeach
@endforeach