public function getIndex() { $stats = array(); $stats['accounts_pending_approval'] = User::query()->pending()->count(); // TODO: unify 'Y'/'N'/0/1 $stats['nominations_pending_review'] = Household::where('draft', 'N')->where('reviewed', 0)->count(); $stats['nominations_approved'] = Household::where('reviewed', 1)->count(); $stats['nominations_reviewed'] = Household::where('approved', 1)->count(); $stats['children_approved'] = Household::where('reviewed', 1)->join('child', 'child.household_id', '=', 'household.id')->count(); $stats['children_reviewed'] = Household::where('household.approved', 1)->join('child', 'child.household_id', '=', 'household.id')->count(); $stats['children_pending'] = Household::where('household.reviewed', 0)->where('household.draft', 'N')->join('child', 'child.household_id', '=', 'household.id')->count(); $stats['drafts'] = Household::query()->draft()->count(); $stats['orgs'] = DB::table('household')->select('affiliation.type', DB::raw('count(case when household.approved = 1 then 1 else null end) as approved'), DB::raw('count(case when household.reviewed = 1 then 1 else null end) as reviewed'), DB::raw('count(case when household.draft = "N" and household.reviewed = 0 then 1 else null end) as pending'))->join('users', 'users.id', '=', 'household.nominator_user_id')->join('affiliation', 'affiliation.id', '=', 'users.affiliation_id')->groupBy('affiliation.type')->get(); return view('admin.dashboard.index', $stats); }
/** * Display the specified user. */ public function show($id) { $household = Household::where('id', '=', $id)->with("child", "address", "phone")->first(); return $this->viewPath("show", $household); }
public function division_report() { $csv = Export::newCSV(["family number", "head of household", "street", "street2", "city", "state", "zip", "phone numbers", "email", "division", "response area"]); $households = Household::where('approved', 1)->get(); foreach ($households as $h) { $a = $h->address->count() ? $h->address[0] : new HouseholdAddress(); $phones = implode(", ", array_map(function ($p) { return $p['phone_number'] . " (" . $p['phone_type'] . ")"; }, $h->phone->toArray())); $csv->insertOne([$h->id, $h->name_last . ", " . $h->name_first, $a->address_street, $a->address_street2, $a->address_city, $a->address_state, $a->address_zip, $phones, $h->email, $a->cmpd_division, $a->cmpd_response_area]); } $csv->output('GiftProjectDivisionReport_' . date("YmdHis") . '.csv'); flush(); exit(0); }