Мне нужно экспортировать окончательную сумму после подсчета всей кредиторской и дебиторской задолженности члена, теперь я делаю две функции, как их объединить
public function memberReceivable($id){
return $this->join('transactions', 'transactions.id', '=', 'member_transactions.transaction_id')
->leftjoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->selectRaw("transactions.unit as currency,sum(transactions.amount) as amount")
->where('accounts.type','accountsReceivable')
->where('member_transactions.member_id',$id)
->groupBy('transactions.unit')->get();
}
public function memberPayable($id){
return $this->join('transactions', 'transactions.id', '=', 'member_transactions.transaction_id')
->leftjoin('accounts', 'accounts.id', '=', 'transactions.account_id')
->selectRaw("transactions.unit as currency,sum(transactions.amount) as amount")
->where('accounts.type','accountsPayable')
->where('member_transactions.member_id',$id)
->groupBy('transactions.unit')->get();
}