Try using 2 separate ->with() statements. One for attendance, and another for vacation. It's hard to tell with it unformatted and jumbled all together, but that looks like it might be it.
May 5, 2018
1
Level 2
Multiple table eloquent
I want data from three table using where clause but employee and attendance table working but vacation table data not working. Please help
Here is my controller :
$first = $request->employee_id_first;
$second = $request->employee_id_last;
$dateYear = date('Y', strtotime($request->datepicker));
$dateMonth = date('m', strtotime($request->datepicker));
$data = Employee::with(['attendance' => function ($query) use ($dateYear,$dateMonth) { $query->whereYear('datetime', $dateYear) ->whereMonth('datetime', $dateMonth); },'vacation' => function ($query) use ($dateYear,$dateMonth){ $query->whereYear('datetime', $dateYear) ->whereMonth('datetime', $dateMonth); }])->get();
Please or to participate in this conversation.