if ($request->filled('components')) {
$query->whereHas('components', function ($query) {
$query->whereIn('waste_component_id', $request->get('components'));
});
}
$posts = Post::whereHas('comments', function (Builder $query) {
$query->where('content', 'like', 'code%');
})
$wastes = Waste::whereHas('components', function ($query) {
$query->where('waste_components.id', 'in', [1,2,3]);
});
$wastes = Waste::whereHas('components', function ($query) {
$query->where('waste_components.id', 'in', [1,2,3]);
});
$wastes = Waste::whereHas('components', function ($query) {
$query->whereIn('waste_components.id', [1,2,3]);
});