Пример #1
0
 /**
  * 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);
 }
Пример #2
0
 /**
  * The getEditProfile method GETs a users profile and returns
  * the view for that profile.
  *
  * @param $id
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function getEditProfile($id)
 {
     $data = ['page_title' => 'Your Profile', 'user' => User::find($id), 'centers' => Center::all()];
     return view('user.profile', $data);
 }