public function show_balance() { return view('user.balance')->with('balance', Balance::where('user_id', Auth::user()->id)->sum('money_amount'))->with('transections', Balance::where('user_id', Auth::user()->id)->orderBy('created_at')->get()); }
/** * Counts the number of centers that are in the red, or * have a negative balance. It also gets the number * of centers that have a positive balance if a * true parameter is passed. * * @param bool $black * @return int */ public static function getNumOfCentersInRed($black = false) { $output = []; foreach (Center::all() as $center) { $balance = Balance::where('center_id', '=', $center->id)->orderBy('date', 'desc')->first(); if ($black) { if ($balance->availableBalance > 0) { array_push($output, $balance->center_id); } } else { if ($balance->availableBalance < 0) { array_push($output, $balance->center_id); } } } return count($output); }
protected function portalEmailBalance($id) { if ( \Auth::user() ) { $userTypeID = \Auth::user()->userTypeId; if ( $userTypeID == 1 || $userTypeID == 2 ) { $authUserId = \Auth::id(); $authEmployee = Employee::where('userId','=',$authUserId)->first(); $accountId = $id; $account = Account::where('id','=',$accountId)->first(); $contact = Contact::where('accountId','=',$accountId)->where('contactTypeId','=',1)->first(); $balance = Balance::where('accountId','=',$accountId)->first()->balance; $data = array( 'contact' => $contact->firstName . ' ' . $contact->lastName, 'id' => $accountId, 'name' => $account->companyName, 'balance' => $balance, ); $test = "hello"; Mail::send('email_invoice_balance', $data, function ($message) use($contact){ $message->from('*****@*****.**', 'D.C.I. Printing & Graphics, Inc.'); $message->to($contact->email, $contact->firstName)->subject('Account Balance'); }); return Redirect::to('/portal-invoices'); } else { return Redirect::to('/account'); } } else { return Redirect::to('/'); } }