samedi 5 octobre 2019

Laravel query results in a complex join scenario

I am using Laravel 5 and I have 4 tables

payroll_template id | user_id | salary_grade | basic_salary

payroll_allowance id |template_id | allowance_label | allowance_value

payroll_deduction id | template_id | deduction_label | deduction_value

payroll_payment id | template_id | user_id

I want to join these tables payroll_template, payroll_allowance, payroll_payment and payroll_deduction and put the field value of allownce_label and deduction_label as the column name and allownce_value and deduction_value as their colomn value from respective tables .

if the users doesn't have allownce_label but others users contains than put the allownce value 0. same for deduction.

I want to show results as

user_id | salary_grade | basic_salary | allowance_label | deduction_label

The allowance_label and deduction_label values should come in in their respective column



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire