I'm trying to display all business locations hours for the current day and if the location does not have hours listed in the database, I'm wanting to show it but as null.
Example:
Business 1: 10:00 am - 5:00 pm
Business 2: 10:00 am - 9:00 pm
Business 3: Closed (null)
Business 4: 10:00 am - 5:00 pm
The issue i'm having is in the controller. It's not showing the nulls with the whereHas
clause.
$Locations = Locations::with('StoreHours', 'Managers', 'ShiftLeads')
->doesntHave('StoreHours')->orWhereHas('StoreHours', function ($query) {
$query->where('opening_time','>=', date('Y-m-d') . ' 00:00:00');
$query->where('opening_time','<=', date('Y-m-d') . ' 23:59:59');
})
->get();
The only data that is showing is if any store has never had store hours. How can I show all stores and get null if there is no hours?