public function save($request, $retirement_fund_id = false)
 {
     $rules = ['identity_card' => 'min:4', 'last_name' => 'min:3|regex:/^[a-záéíóúàèìòùäëïöüñ\\s]+$/i', 'first_name' => 'min:3|regex:/^[a-záéíóúàèìòùäëïöüñ\\s]+$/i', 'home_phone_number' => 'numeric', 'home_cell_phone_number' => 'numeric'];
     $messages = ['identity_card.min' => 'El mínimo de caracteres permitidos para Carnet de Identidad es 4', 'last_name.min' => 'El mínimo de caracteres permitidos para apellido paterno es 3', 'last_name.regex' => 'Sólo se aceptan letras para apellido paterno', 'first_name.min' => 'El mínimo de caracteres permitidos para nombres es 3', 'first_name.regex' => 'Sólo se aceptan letras para primer nombre', 'home_phone_number.numeric' => 'Sólo se aceptan números para teléfono', 'home_cell_phone_number.numeric' => 'Sólo se aceptan números para celular'];
     $validator = Validator::make($request->all(), $rules, $messages);
     if ($validator->fails()) {
         return redirect('retirement_fund/' . $retirement_fund_id)->withErrors($validator)->withInput();
     } else {
         $RetirementFund = RetirementFund::afiIs($retirement_fund_id)->where('deleted_at', '=', null)->orderBy('id', 'desc')->first();
         $applicant = Applicant::retirementFundIs($RetirementFund->id)->orderBy('id', 'asc')->first();
         if (!$applicant) {
             $applicant = new Applicant();
         }
         $applicant_type = ApplicantType::where('id', '=', $request->type_applicant)->first();
         $applicant->applicant_type_id = $applicant_type->id;
         $applicant->retirement_fund_id = $RetirementFund->id;
         $applicant->identity_card = trim($request->identity_card);
         $applicant->last_name = trim($request->last_name);
         $applicant->mothers_last_name = trim($request->mothers_last_name);
         $applicant->first_name = trim($request->first_name);
         $applicant->kinship = trim($request->kinship);
         $applicant->home_address = trim($request->home_address);
         $applicant->home_phone_number = trim($request->home_phone_number);
         $applicant->home_cell_phone_number = trim($request->home_cell_phone_number);
         $applicant->work_address = trim($request->work_address);
         $applicant->save();
         $message = "Información de Solicitante actualizada con éxito";
     }
     Session::flash('message', $message);
     return redirect('retirement_fund/' . $retirement_fund_id);
 }
Пример #2
0
    public function getFullNametoPrint()
    {
        return $this->first_name . ' ' . $this->last_name . ' ' . $this->mothers_last_name;
    }
    public function getParentesco()
    {
        if ($this->applicant_type->id == 3) {
            return $this->kinship;
        } else {
            return $this->applicant_type->name;
        }
    }
    public function getFullDateNactoPrint()
    {
        return Util::getfulldate($this->fech_nac);
    }
    public function getFullNumber()
    {
        return $this->home_phone_number . ' ' . $this->home_cell_phone_number;
    }
    public function getFullName()
    {
        return $this->last_name . ' ' . $this->mothers_last_name . ' ' . $this->first_name;
    }
}
Applicant::created(function ($applicant) {
    Activity::createdApplicant($applicant);
});
Applicant::updating(function ($applicant) {
    Activity::updateApplicant($applicant);
});
 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;
 }