public function getData($afid)
 {
     $affiliate = Affiliate::idIs($afid)->first();
     $spouse = Spouse::affiliateidIs($afid)->first();
     if (!$spouse) {
         $spouse = new Spouse();
     }
     $retirement_fund = RetirementFund::afiIs($afid)->first();
     if (!$retirement_fund) {
         $now = Carbon::now();
         $last_retirement_fund = RetirementFund::whereYear('created_at', '=', $now->year)->where('deleted_at', '=', null)->orderBy('id', 'desc')->first();
         $retirement_fund = new RetirementFund();
         if ($last_retirement_fund) {
             $number_code = Util::separateCode($last_retirement_fund->code);
             $code = $number_code + 1;
         } else {
             $code = 1;
         }
         $retirement_fund->code = $code . "/" . $now->year;
         $retirement_fund->affiliate_id = $afid;
         $retirement_fund->save();
     }
     $applicant = Applicant::retirementFundIs($retirement_fund->id)->first();
     if (!$applicant) {
         $applicant = new Applicant();
     }
     $requirements = Requirement::modalityIs($retirement_fund->retirement_fund_modality_id)->get();
     $documents = Document::retirementFundIs($retirement_fund->id)->get();
     $antecedents = Antecedent::retirementFundIs($retirement_fund->id)->get();
     if ($retirement_fund->retirement_fund_modality_id) {
         $info_modality = TRUE;
     } else {
         $info_modality = FALSE;
     }
     if ($applicant->identity_card) {
         $info_applicant = TRUE;
     } else {
         $info_applicant = FALSE;
     }
     if (Document::retirementFundIs($retirement_fund->id)->first()) {
         $info_documents = TRUE;
     } else {
         $info_documents = FALSE;
     }
     if (Antecedent::retirementFundIs($retirement_fund->id)->first()) {
         $info_antecedents = TRUE;
     } else {
         $info_antecedents = FALSE;
     }
     if ($retirement_fund->comment) {
         $info_comment = TRUE;
     } else {
         $info_comment = FALSE;
     }
     $lastContribution = Contribution::affiliateidIs($affiliate->id)->orderBy('month_year', 'desc')->first();
     $affiliate->service_start_date = $affiliate->date_entry;
     $affiliate->service_end_date = $lastContribution->month_year;
     $data = array('affiliate' => $affiliate, 'spouse' => $spouse, 'retirement_fund' => $retirement_fund, 'applicant' => $applicant, 'requirements' => $requirements, 'documents' => $documents, 'antecedents' => $antecedents, 'info_modality' => $info_modality, 'info_applicant' => $info_applicant, 'info_documents' => $info_documents, 'info_antecedents' => $info_antecedents, 'info_comment' => $info_comment);
     $data = array_merge($data, self::getViewModel());
     return $data;
 }