Level 51
1 like
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I've been try to merge three queries but have had a hard time doing so.here is the code.
public function precise_transact(Request $request){
$month = $request->month;
$year = $request->year;
$date = $request->date;
$date_query = Transaction::whereRaw("day(created_at)=?",[$date]);
$year_query = Transaction::whereRaw("year(created_at)=?",[$year]);
$transactions = Transaction::whereRaw("month(created_at)=?",[$month])
->union($date_query)
->union($year_query)
->get();
}
Please or to participate in this conversation.