/**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id)
 {
     $id_father = Input::get('datafather.id');
     $id_mother = Input::get('datamother.id');
     $id_spouse = Input::get('dataspouse.id');
     $id_present_address = Input::get('addresspresent.id');
     $id_original_address = Input::get('addressoriginal.id');
     $father = Input::get('datafather');
     $mother = Input::get('datamother');
     $spouse = Input::get('dataspouse');
     $presentaddress = Input::get('addresspresent');
     $originaladdress = Input::get('addressoriginal');
     $name_father = Input::get('datafather.father_name');
     $surname_father = Input::get('datafather.father_surname');
     $name_mother = Input::get('datamother.mother_name');
     $surname_mother = Input::get('datamother.mother_surname');
     $name_spouse = Input::get('dataspouse.spouse_name');
     $surname_spouse = Input::get('dataspouse.spouse_surname');
     $present_address = Input::get('addresspresent.present_address');
     $original_address = Input::get('addressoriginal.original_address');
     if (!$id_present_address) {
         if ($present_address != null) {
             $addresspresent = new AddressPresent();
             $addresspresent->fill($presentaddress);
             $addresspresent->save();
         }
     } else {
         $addresspresent1 = AddressPresent::find($id_present_address);
         $addresspresent1->fill($presentaddress);
         $addresspresent1->save();
     }
     if (!$id_original_address) {
         if ($original_address != null) {
             $addressoriginal = new AddressOriginal();
             $addressoriginal->fill($originaladdress);
             $addressoriginal->save();
         }
     } else {
         $addressoriginal1 = AddressOriginal::find($id_original_address);
         $addressoriginal1->fill($originaladdress);
         $addressoriginal1->save();
     }
     if (!$id_mother) {
         if ($name_mother != null || $surname_mother != null) {
             $datamother = new DataMother();
             $datamother->fill($mother);
             $datamother->save();
         }
     } else {
         $datamother1 = DataMother::find($id_mother);
         $datamother1->fill($mother);
         $datamother1->save();
     }
     if (!$id_father) {
         if ($name_father != null || $surname_father != null) {
             $datafather = new DataFather();
             $datafather->fill($father);
             $datafather->save();
         }
     } else {
         $datafather1 = DataFather::find($id_father);
         $datafather1->fill($father);
         $datafather1->save();
     }
     if (!$id_spouse) {
         if ($name_spouse != null || $surname_spouse != null) {
             $dataspouse = new DataSpouse();
             $dataspouse->fill($spouse);
             if (Input::has('dataspouse.nametitle.id')) {
                 $nametitle = NameTitle::find(Input::get('dataspouse.nametitle.id'));
                 $dataspouse->nametitle()->associate($nametitle);
             }
             $dataspouse->save();
         }
     } else {
         $dataspouse1 = DataSpouse::find($id_spouse);
         $dataspouse1->fill($spouse);
         if (Input::has('dataspouse.nametitle.id')) {
             $nametitle = NameTitle::find(Input::get('dataspouse.nametitle.id'));
             $dataspouse1->nametitle()->associate($nametitle);
         }
         $dataspouse1->save();
     }
     $criminalhistory = CriminalHistory::find($id);
     $criminalhistory->fill(Input::except(["datacase", "addressoffice", "addressoriginal", "addresspresent", "datachild", "datafather", "datamother", "dataspouse"]));
     if (Input::has('nametitle.id')) {
         $nametitle = NameTitle::find(Input::get('nametitle.id'));
         $criminalhistory->nametitle()->associate($nametitle);
     }
     if ($datamother != null) {
         $criminalhistory->datamother()->associate($datamother);
     }
     if ($datafather != null) {
         $criminalhistory->datafather()->associate($datafather);
     }
     if ($dataspouse != null) {
         $criminalhistory->dataspouse()->associate($dataspouse);
     }
     if ($addressoriginal != null) {
         $criminalhistory->addressoriginal()->associate($addressoriginal);
     }
     if ($addresspresent != null) {
         $criminalhistory->addresspresent()->associate($addresspresent);
     }
     $criminalhistory->save();
     Event::fire(new EditDataPersonCrimeEvent($criminalhistory));
     return $criminalhistory;
 }