8 months ago

Raw Query To Eloquent Query builer

Posted 8 months ago by kshitizmittal

I want to convert this raw query to eloquent, but it seems to be complex, please help me out.

select one.emp_id,one.date,one.punch_in,one.punch_out,two.type_code,two.start_date,two.end_date,three.week_off,three.month,three.year,four.holidaydate
from punchreports as one
left join (SELECT applyleaves.emp_id,leavetypes.type_code,applyleaves.start_date,applyleaves.end_date FROM applyleaves INNER JOIN leavetypes on applyleaves.leave_type_id = leavetypes.type_id) as two
on (one.emp_id = two.emp_id and (one.date >= two.start_date AND one.date <= two.end_date ))
LEFT JOIN rosters as three
on (one.emp_id = three.emp_id AND (DATE_FORMAT(one.date, "%M") = three.month AND DATE_FORMAT(one.date, "%Y") = three.year ))
LEFT JOIN (select assigntandas.emp_id,holidays.holidaydate from assigntandas INNER JOIN holidays on assigntandas.holiday_calendar = holidays.parentid) as four
on (one.emp_id = four.emp_id AND one.date = four.holidaydate)
where one.emp_id = '710102'

Please sign in or create an account to participate in this conversation.