I'm trying to retrieved records base on its 'created_at' timestamp column, where yesterday is the start date and retrieved records until to the start of the current month
$h_msg1 = m_chat_history::where('employee_id',$request->other_id)->whereNull('to_group')->where('to_employee_id',$request->id)->whereBetween('created_at', [
Carbon::parse('yesterday')->startOfDay(),
Carbon::now()->endOfMonth(),
])->get();
But unfortunately it throws me and empty result, any help, ideas, clues, suggestions, recommendations please?
try below code
$first_day_this_month = date('Y-m-01 H:s:i');
$yesterDay = date('Y-m-d H:s:i',strtotime("-1 days"));
$record = m_chat_history::whereBetween('created_at',[$first_day_this_month, $yesterDay])->get();
Yo need to use startOfMonth according to your message:
$h_msg1 = m_chat_history::where('employee_id',$request->other_id)->whereNull('to_group')->where('to_employee_id',$request->id)->whereBetween('created_at', [
Carbon::parse('yesterday')->startOfDay(),
Carbon::now()->startOfMonth()
])->get();