Aug 9, 2019
2
Level 5
calculating attendance total present and absent laravel
guys i need to calculate the attendance of of my employees.
this is my emp_attendance table has columns
att_date emp_id att-count reason
01/07 1 1
01/07 2 0 Leave fever
02/07 1 0.5 halfday fever
02/07 2 1
03/07 1 0 absent
the problem is
so in the above for employee 1
the present days is 1.5 (1+0.5)
the absentdays is 1.5 (1+0.5) (here the problem is the 0 are absent so that must be count and 0.5 is half day that must be sum and then both must be added ). so the count of 0 is 1 and the sum of 0.5 is 0.5 so adding both 1.5 is the absent days
total days are 3 (1 + 1 + 1)
these are my models
//employee model
public function empattendance()
{
return $this->hasMany('App\EmpAttendance', 'emp_id');
}
//empattendance model
public function employee()
{
return $this->belongsTo('App\Employee', 'emp_id');
}
iam expecting the output as
Sno Name TotalDays Present Absent
1 MANI 31 25 6
2 ABDUL 31 23 8
how to display this??
Please or to participate in this conversation.