是否可以在查询中获取带有枚举数据类型的扣除值?

时间:2019-09-22 09:29:09

标签: php mysql laravel

我正在尝试在excel表中制作工资单月度报告,以下是我在控制器中的功能。请参阅附件以及此问题。我的预期输出在同一附件中突出显示。

public function postPayrollMonthlyReport()
{

    $departments_id = \Request::get('departments_id');
    $month = \Request::get('month');

    $data = EmployeePayroll::select('users.first_name as first_name','users.last_name as last_name','payroll_salary_deduction.deduction_label' , 'payroll_salary_deduction.deduction_value')
                      ->join('users','users.id','=','payroll_manage_employee_payroll.user_id')
                      ->join('payroll_salary_template','payroll_salary_template.salary_template_id','=','payroll_manage_employee_payroll.salary_template_id')
                      ->join('payroll_salary_deduction','payroll_salary_deduction.salary_template_id','=','payroll_manage_employee_payroll.salary_template_id')
                    ->where('users.departments_id',$departments_id)
                    ->get();

    return \Excel::create('monthly_payroll_report('.$month.')', function($excel) use ($data) {
      $excel->sheet('mySheet', function($sheet) use ($data)
        {
            $sheet->fromArray($data);
        });
    })->download(xls);

}

enter image description here

0 个答案:

没有答案