I have a user table and daily_attendance table. In users table i have id column as primary key, name column where i store employee name and In salary table i have emplyeeid column where i store user id, todaysdate columns where i store the date, month column and year column
I want to get the full month salary of each employee with employee name in single row.
This is my code
$query = DB::table('users')->select(\DB::raw('users.id, users.name,SUM(daily_attendance.day_salary) as day_salary'))
->leftJoin('daily_attendance', 'daily_attendance.employee_id', '=', 'users.id')
->where('daily_attendance.month',$current_month)
->where('daily_attendance.year',$year)
->where('daily_attendance.status',1)
->groupBy('users.id')
->get();
its giving me employee id and salary of the employee.But i am not getting the employee name.If i use users.* it gives me access violation error. please help me to do thi.
can i achieve this with group_concat or using laravel sub queries..