First problem:
since you are using a Closure you need to tell it which variable to "import" into it:
function ($query) use ($category_id) {}
That should fix it. Is there a reason you don't use Models and Relations?
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community