Variable used for joining conditional query scope is getting overwritten
The two dd($resourceSchedule->count() ) results give different values. I need the $resourceSchedule variable to remain unchanged in order to build the conditional query.
The reason why your first dd() is 1, and the second is 0, is because on your first one, you hadn't chained on -> endDateNull() yet for the first dd(), but the second one includes that in the where clause.
The query Builder chains anything you add to it, even if it's in a separate statement.
Fine enough. Is there any workaround for this chaining issue here. Otherwise instead of One function getResourceItemSchedule, I may have to create three functions for location, service, and provider. Most of these will be repetitive code.