public static function getViewModel() { $modality = RetirementFundModality::all(); $modalities_list = array('' => ''); foreach ($modality as $item) { $modalities_list[$item->id] = $item->name; } $city = City::all(); $cities_list = array('' => ''); foreach ($city as $item) { $cities_list[$item->id] = $item->name; } $antecedent_files = AntecedentFile::all(); return ['modalities_list' => $modalities_list, 'cities_list' => $cities_list, 'antecedent_files' => $antecedent_files]; }
/** * Display the specified resource. * * @param int $id * @return \Illuminate\Http\Response */ public function getData($affiliate) { $affiliate = Affiliate::idIs($affiliate)->first(); $spouse = Spouse::affiliateidIs($affiliate->id)->first(); if (!$spouse) { $spouse = new Spouse(); } if ($affiliate->gender == 'M') { $gender_list = ['' => '', 'C' => 'CASADO', 'S' => 'SOLTERO', 'V' => 'VIUDO', 'D' => 'DIVORCIADO']; } elseif ($affiliate->gender == 'F') { $gender_list = ['' => '', 'C' => 'CASADA', 'S' => 'SOLTERA', 'V' => 'VIUDA', 'D' => 'DIVORCIADA']; } if ($affiliate->city_identity_card_id) { $affiliate->city_identity_card = City::idIs($affiliate->city_identity_card_id)->first()->shortened; } else { $affiliate->city_identity_card = ''; } if ($affiliate->city_birth_id) { $affiliate->city_birth = City::idIs($affiliate->city_birth_id)->first()->name; } else { $affiliate->city_birth = ''; } if ($affiliate->city_address_id) { $affiliate->city_address = City::idIs($affiliate->city_address_id)->first()->name; } else { $affiliate->city_address = ''; } if ($affiliate->city_address_id || $affiliate->zone || $affiliate->Street || $affiliate->number_address || $affiliate->phone || $affiliate->cell_phone) { $info_address = TRUE; } else { $info_address = FALSE; } if ($spouse->identity_card) { $info_spouse = TRUE; } else { $info_spouse = FALSE; } $last_contribution = Contribution::affiliateidIs($affiliate->id)->orderBy('month_year', 'desc')->first(); $consulta = DB::table('affiliates')->select(DB::raw('SUM(contributions.gain) as gain, SUM(contributions.public_security_bonus) as public_security_bonus, SUM(contributions.quotable) as quotable, SUM(contributions.total) as total, SUM(contributions.retirement_fund) as retirement_fund, SUM(contributions.mortuary_quota) as mortuary_quota'))->leftJoin('contributions', 'affiliates.id', '=', 'contributions.affiliate_id')->where('affiliates.id', '=', $affiliate->id)->get(); foreach ($consulta as $item) { $total_gain = Util::formatMoney($item->gain); $total_public_security_bonus = Util::formatMoney($item->public_security_bonus); $total_quotable = Util::formatMoney($item->quotable); $total_retirement_fund = Util::formatMoney($item->retirement_fund); $total_mortuary_quota = Util::formatMoney($item->mortuary_quota); $total = Util::formatMoney($item->total); } $data = ['affiliate' => $affiliate, 'spouse' => $spouse, 'gender_list' => $gender_list, 'info_address' => $info_address, 'info_spouse' => $info_spouse, 'last_contribution' => $last_contribution, 'total_gain' => $total_gain, 'total_public_security_bonus' => $total_public_security_bonus, 'total_quotable' => $total_quotable, 'total_retirement_fund' => $total_retirement_fund, 'total_mortuary_quota' => $total_mortuary_quota, 'total' => $total]; $data = array_merge($data, self::getViewModel()); return $data; }