private function getUnactionedLoanCount() { $newLoans = Loan::where('status_id', 1)->get()->toArray(); foreach ($newLoans as $index => $loan) { $transactions = Transaction::where('loan_id', $loan['id'])->where('user_id', '!=', $loan['user_id'])->get()->toArray(); if (isset($transactions[0])) { // Remove this loan unset($newLoans[$index]); } } return array('unactionedLoanCount' => count($newLoans)); }