pluck('id')->first(); $cost_of_good_account_id = \Streamline\Models\ChartOfAccount::where('type', 7)->pluck('id')->first(); foreach ($debtors as $invoice){ //Consultations / Services if($invoice->tag_id == 6 || $invoice->tag_id == 8 || $invoice->tag_id == 7 || $invoice->tag_id == 10){ Debtor::where('id', $invoice->id)->update(['income_account'=> 7]); } //Drugs / Treatments elseif ($invoice->tag_id == 3 || $invoice->tag_id == 1){ Debtor::where('id', $invoice->id)->update([ 'income_account'=> 4, 'inventory_account'=> $inventory_account_id, 'cost_of_goods_account'=> $cost_of_good_account_id ]); } //Sundries elseif ($invoice->tag_id == 5 ){ Debtor::where('id', $invoice->id)->update([ 'income_account'=> 4, 'inventory_account'=> $inventory_account_id, 'cost_of_goods_account'=> $cost_of_good_account_id ]); } //Investigations elseif ($invoice->tag_id == 2 ){ Debtor::where('id', $invoice->id)->update(['income_account'=> 11]); } //Procedures elseif ($invoice->tag_id == 4 ){ Debtor::where('id', $invoice->id)->update(['income_account'=> 8]); } } foreach ($debt_plans as $invoice){ //Consultations / Services if($invoice->tag_id == 6 || $invoice->tag_id == 8 || $invoice->tag_id == 7 || $invoice->tag_id == 10){ DebtPlan::where('id', $invoice->id)->update(['income_account'=> 7]); } //Drugs / Treatments elseif ($invoice->tag_id == 3 || $invoice->tag_id == 1){ DebtPlan::where('id', $invoice->id)->update([ 'income_account'=> 4, 'inventory_account'=> $inventory_account_id, 'cost_of_goods_account'=> $cost_of_good_account_id ]); } //Sundries elseif ($invoice->tag_id == 5 ){ DebtPlan::where('id', $invoice->id)->update([ 'income_account'=> 4, 'inventory_account'=> $inventory_account_id, 'cost_of_goods_account'=> $cost_of_good_account_id ]); } //Investigations elseif ($invoice->tag_id == 2 ){ DebtPlan::where('id', $invoice->id)->update(['income_account'=> 11]); } //Procedures elseif ($invoice->tag_id == 4 ){ DebtPlan::where('id', $invoice->id)->update(['income_account'=> 8]); } } foreach ($insurance_expenditures as $invoice){ //Consultations / Services if($invoice->tag_id == 6 || $invoice->tag_id == 8 || $invoice->tag_id == 7 || $invoice->tag_id == 10){ InsuranceExpenditure::where('id', $invoice->id)->update(['income_account'=> 7]); } //Drugs / Treatments elseif ($invoice->tag_id == 3 || $invoice->tag_id == 1){ InsuranceExpenditure::where('id', $invoice->id)->update([ 'income_account'=> 4, 'inventory_account'=> $inventory_account_id, 'cost_of_goods_account'=> $cost_of_good_account_id ]); } //Sundries elseif ($invoice->tag_id == 5 ){ InsuranceExpenditure::where('id', $invoice->id)->update([ 'income_account'=> 12, 'inventory_account'=> $inventory_account_id, 'cost_of_goods_account'=> $cost_of_good_account_id ]); } //Investigations elseif ($invoice->tag_id == 2 ){ InsuranceExpenditure::where('id', $invoice->id)->update(['income_account'=> 11]); } //Procedures elseif ($invoice->tag_id == 4 ){ InsuranceExpenditure::where('id', $invoice->id)->update(['income_account'=> 8]); } } } }