Last active
July 26, 2018 03:40
-
-
Save marufmax/637aa5d3fcbb927a16f6bbb419e1f956 to your computer and use it in GitHub Desktop.
Eloquent with raw sql and eqlouent where join select
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Raw SQL | |
$present = DB::select(DB::raw("SELECT count(had.emp_id) as present FROM hta_emp_personal hep | |
INNER JOIN hta_attendance_details had ON hep.emp_id=had.emp_id | |
AND had.att_date='2018-07-07 00:00:00' | |
AND had.status='P'")); | |
// ORM | |
$present = DB::table('hta_attendance_details') | |
->join('hta_emp_personal', 'hta_emp_personal.emp_id', '=', 'hta_attendance_details.emp_id') | |
->select('hta_attendance_details.*', 'hta_emp_personal.emp_id') | |
->where([ | |
['hta_attendance_details.status', 'P'], | |
['hta_attendance_details.att_date', '2018-07-07 00:00:00'] | |
]) | |
->count(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment