Skip to content
Advertisement

Category filtering in Laravel

Hey guys I’m currently trying to resolve why my legacy code doesn’t work the way it was intended to do so. It’s a basic category filter. My current problem is that I don’t really know what to fix.

I tried changing up whereHas, whereIn, orWhere query statement. When I changed orWhere to just simply where, the filter worked only if one category was selected.

If anyone has any ideas to fix my problem, help would be gladly appreciated.

My code is below :

Backend(InternController.php) :

JavaScript

Frontend(intern.blade.php):

JavaScript

Advertisement

Answer

Fixed, finally.

Deleted the foreach statement in the whereHas body.

final code looks like this

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement